I made an animation script for a cup, and When the player has the tool equipped, and the player clicks it plays the animation. But it doesnt work.
things to know -- Animis the name of the animation and it is inside the script. Tool is a cup. here is my script
local Tool = script.Parent local Anim = nil local Ready = true Tool.Activated:Connect(function() if Tool.Parent.Humanoid.Health > 0 and Ready == true then Ready = false Anim = Tool.Parent.Humanoid:LoadAnimation(script:WaitForChild("Anim")) Anim:Play() wait(2) Ready = true end end) Tool.Unequipped:Connect(function() if Anim then Anim:Stop() end Ready = true end)
Next time explain your question please, for example;
Is there any errors?
Have you checked the output?
etc.
The only thing I can suggest is to name the animation differently and place it somewhere else like ReplicatedStorage
I will re-write the script but make sure the Animation is named "CupAnimation" and it placed in ReplicatedStorage
Script;
local Cup = script.Parent local CupAnime = game.ReplicatedStorage:WaitForChild('CupAnimation') local Ready = true Cup.Activated:Connect(function() -- use Connect with cap C if Cup.Parent.Parent:WaitForChild('Humanoid').Health >= 1 then local plr = Cup.Parent.Parent if Ready = true then Ready = false local LoadAnime = plr:WaitForChild('Humanoid'):LoadAnimation(CupAnime) LoadAnime:Play() -- if it doesn't work change to CupAnime:Play() wait(2) Ready = true end end end) Tool.Unequipped:Connect(function() Anim:Stop() Ready = true end)
Now I Wrote this from scratch; here;s a few things you can try if it STILL Doesn't work;
Change LoadAnime:Play() with CupAnime:Play()
Change
Cup.Parent.Parent:WaitForChild('Humanoid').Health >= 1 then
toCup.Parent.:WaitForChild('Humanoid').Health >= 1 then
(deletes a parent) AND Changelocal plr = Cup.Parent.Parent
tolocal plr = Cup.Parent
Make sure animation is in Replicated Storage and make sure everything is correct (in variables)
Hope this helped, if helped then Please upvote and accept answer ;)
Good luck have fun developing!