Hello developers, I’ve been trying to code a tool, a flashlight to be specific, the flashlight is finished and is fully functional as long as it’s inside workspace but whenever I move it’s location inside StarterPack it breaks and it no longer works, I’ve searched the dev forum but couldn’t find anything relating to this issue.
My code:
local Player = game.Players.LocalPlayer
local function FindCharacter()
local character = Player.Character
return character
end
local character = FindCharacter()
if not character then return end
local tool = script.Parent
local animation = tool:WaitForChild("TurnOn/Off")
local Humanoid = character:WaitForChild("Humanoid")
local animationTrack = Humanoid:LoadAnimation(animation)
local NeonPart = tool.Neon
local SpotLight = NeonPart.SpotLight
local debounce = false
local debounceTime = 1
tool.Activated:Connect(function()
if not debounce then
print("tool activated")
debounce = true
animationTrack:Play()
SpotLight.Enabled = not SpotLight.Enabled
if SpotLight.Enabled then
NeonPart.Transparency = 0.5
else
NeonPart.Transparency = 1
end
wait(debounceTime)
debounce = true
end
end)
Also this is my first time making an actual topic so I apologize for any issues.