Hello,
Here’s what I’d like for the script to do:
- If tool equipped and clicked, perform an animation
- after the animation has completed, change the value
- be able to restart the animation as soon as the animation has finished
What it does
- when tool equipped and clicked, it performs the animation
- however, if clicked multiple times, it restarts the animation
- continuously loops unless unequipped
- doesn’t change the value
also i heard local anim = humanoid:LoadAnimation(emote)
is deprecated. What is the better replacement for this?
here is the code
game.Players.PlayerAdded:Connect(function(player)
local news = player:WaitForChild("leaderstats"):WaitForChild("news")
player.CharacterAdded:Connect(function(character)
local read = Instance.new("Animation")
local humanoid = character:WaitForChild("Humanoid")
read.Parent = humanoid
read.AnimationId = "rbxassetid://11827469203"
repeat task.wait() until character.Parent == workspace
local readanim = humanoid:LoadAnimation(read)
readanim.Looped = true
local tool = character:WaitForChild("NewsTool")
tool.Equipped:Connect(function()
tool.Activated:Connect(function()
readanim:Play()
readanim.Stopped:wait()
news.Value += 1
end)
tool.Deactivated:Connect(function()
print("deactivated")
--readanim:Stop()
end)
end)
tool.Unequipped:Connect(function()
readanim:Stop()
end)
end)
end)
`