I made an animating script which should play when my tool gets equipped, but it doesn’t work they are no errors sorry if the mistake is silly, I haven’t coded in a few years
local player = game:GetService("Players").LocalPlayer
local anims = script.Parent.Hold
local loadedAnims
local tool = script.Parent
local Animator
tool.Equipped:Connect(function()
Animator = player.Character:WaitForChild("Humanoid"):WaitForChild("Animator")
loadedAnims = Animator:LoadAnimation(anims)
loadedAnims:Play()
end)
tool.Unequipped:Connect(function()
loadedAnims:Stop()
end)
seems like you are trying to load the animation from the client + the script is inside the tool
when the tool is equipped, the tool is inside the character so you don’t need to get the character from the local player
local anims = script.Parent.Hold
local loadedAnims
local tool = script.Parent
local Animator
local player
tool.Equipped:Connect(function()
player = tool.Parent
Animator = player.Character:WaitForChild("Humanoid"):WaitForChild("Animator")
loadedAnims = Animator:LoadAnimation(anims)
loadedAnims:Play()
end)
tool.Unequipped:Connect(function()
loadedAnims:Stop()
end)
Stack Begin - Studio
13:48:15.067 Script 'Players.ZINTICK.Backpack.Tool.Script', Line 9 - Studio - Script:9
13:48:15.067 Stack End - Studio
13:48:15.325 Players.ZINTICK.Backpack.Tool.Script:15: attempt to index nil with 'Stop' -
13:48:15.325 Stack Begin - Studio
13:48:15.325 Script 'Players.ZINTICK.Backpack.Tool.Script', Line 15 - Studio - Script:15
13:48:15.326 Stack End - Studio
13:48:15.583 Character is not a valid member of Backpack "Players.ZINTICK.Backpack"