Hello devs, I’m working on game and I created tool with LocalScript with it :
local player = game:GetService("Players").LocalPlayer
local character = player.Character or player.CharacterAdded:Wait()
local humanoid = character:WaitForChild("Humanoid")
local holdAnim = humanoid.Animator:LoadAnimation(script.Parent:WaitForChild("Hold"))
local toggleAnim = humanoid.Animator:LoadAnimation(script.Parent:WaitForChild("Toggle"))
local event = script.Parent:WaitForChild("Event")
local toggle = false
local debounce = false
script.Parent.Unequipped:Connect(function()
holdAnim:Stop()
toggleAnim:Stop()
end)
script.Parent.Equipped:Connect(function()
if toggle == true then
holdAnim:Play()
end
end)
script.Parent.Activated:Connect(function()
if toggle == false and debounce == false then
debounce = true
toggle = true
script.Parent.Sound:FireServer()
toggleAnim:Play()
toggleAnim.Stopped:Wait()
event:FireServer()
holdAnim:Play()
debounce = false
elseif toggle == true and debounce == false then
debounce = true
toggle = false
script.Parent.Sound:FireServer()
holdAnim:Stop()
toggleAnim:Play()
toggleAnim.Stopped:Wait()
event:FireServer()
debounce = false
end
end)
At first it works fine but after player dies this error shows up :
Hope you can help me! Thanks!