Hey! I’m trying to make a flashlight script but the inputs or the event or the script doesn’t work. Can anyone find the error?
Local Script
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local UIS = game:GetService("UserInputService")
local Player = game:GetService("Players").LocalPlayer
local Character = Player.Character or Player.CharacterAdded:Wait()
local ToggleEvent = script:WaitForChild("ToggleEvent")
local Debounce = false
local function Activator()
if not _G.CheckIfCan(Character, "Any") then
Debounce = true
ToggleEvent:FireServer(true)
wait(0.5)
Debounce = false
end
end
delay(0.5, function()
local Table = {
Title = "Body Flashlight",
Text = "Press 'J' to toggle.",
Duration = 30,
Button1 = "Close"
}
ReplicatedStorage.Events2.Notification:Fire(Table, "beep")
end)
UIS.InputBegan:Connect(function(Input)
if Debounce then
return
end
if Input.KeyCode == Enum.KeyCode.J then
Activator()
end
end)```
Server Script
```lua
local Character = script.Parent.Parent
local Flashlight = script.Parent.Parent.BodyFlashlight_1.Parts.Torso.Model.LP1
local Parts = Flashlight.Parent.Parent.Parent
local RemoteEvent = script.Parent.ToggleEvent
local ToggleSound = Flashlight.ToggleSound
local EnabledV = script.Parent.EnabledV
local function Toggler(parameter)
if parameter == true then
Flashlight.A1.P1.Enabled = true
Flashlight.From.SpotLight.Enabled = true
Flashlight.Enabled = true
EnabledV.Value = true
Flashlight.Material = Enum.Material.Neon
local dSG = Instance.new("BoolValue", Flashlight.From)
dSG.Value = true
ToggleSound:Play()
else
Flashlight.A1.P1.Enabled = false
Flashlight.From.SpotLight.Enabled = false
Flashlight.Enabled = false
EnabledV.Value = false
Flashlight.From.dSG:Destroy()
ToggleSound:Play()
end
end
RemoteEvent.OnServerEvent:Connect(Toggler)```