FlashLight
Local
LocalScript
local uis = game:GetService("UserInputService")
local player = game.Players.LocalPlayer
local brightness = 15
uis.InputBegan:Connect(function(input)
if input.UserInputType == Enum.UserInputType.Keyboard then
if input.KeyCode == Enum.KeyCode.F then
local flashlight = player.Character.HumanoidRootPart:FindFirstChild("SpotLight")
if not flashlight then
local flashlight = Instance.new("SpotLight")
flashlight.Brightness = 15
flashlight.Parent = player.Character.HumanoidRootPart
else
flashlight:Destroy()
end
end
end
end)
Server
LocalScript
local uis = game:GetService("UserInputService")
local player = game.Players.LocalPlayer
local rs = game:GetService("ReplicatedStorage")
local flashEvent = rs:WaitForChild("FlashEvent")
uis.InputBegan:Connect(function(input)
if input.UserInputType == Enum.UserInputType.Keyboard then
if input.KeyCode == Enum.KeyCode.F then
flashEvent:FireServer()
end
end
end)
ServerScriptService
local rs = game:GetService("ReplicatedStorage")
local flashEvent = rs:WaitForChild("FlashEvent")
local brightness = 30
flashEvent.OnServerEvent:Connect(function(player)
local flashlight = player.Character.HumanoidRootPart:FindFirstChild("SpotLight")
if not flashlight then
local flashlight = Instance.new("SpotLight")
flashlight.Brightness = brightness
flashlight.Parent = player.Character.HumanoidRootPart
else
flashlight:Destroy()
end
end)