Why Wont This Animation Play?

Hey there! I am having a bit of a problem. You see, I have this tool that I need to play an animation when it is activated, but it doesnt seem to work. I asked the roblox “assistant”, but I feel as if it isnt 100% the best all the time.

script.Parent.Activated:Connect(function(player)
	local hum = player.Character:WaitForChild("Humanoid")
	local anim = hum:LoadAnimation(script:FindFirstChildOfClass("Animation"))
	anim:Play()
end)

Capture.PNG541

2 Likes

Maybe it’s because you put an argument in the Activated function, that function does not need the player argument there.

You could get the player in different ways, maybe try this:

local player= script.Parent.Parent.Parent

script.Parent.Activated:Connect(function()
	print(player.Name)
    local hum = player.Character:WaitForChild("Humanoid")
	local anim = hum:LoadAnimation(script:FindFirstChildOfClass("Animation"))
	anim:Play()
end)
2 Likes

Alright, let me see if this works rq

Thanks so much! haha im still pretty new to coding!

2 Likes

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.