Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Animation will not play?

I am currently working on a game. In this game you can vault, and i need an animation to play when you do so. Sadly, i wasn't able to make the animation play.

Script in the object to vault over (server):

script.Parent.Touch.Touched:Connect(function(hit)
	local humanoid = hit.Parent:FindFirstChild("Humanoid")
	print(hit.Name.." touched.")
	if humanoid then
		local player = game.Players:GetPlayerFromCharacter(hit.Parent)
		
		hit.Parent:FindFirstChild("VaultEvent"):FireClient(player)
		
		print("Client has been fired")
	end
end)

Script in the player character:

script.Parent.VaultEvent.OnClientEvent:Connect(function(player)
	script.Parent:FindFirstChild("Humanoid"):LoadAnimation(script.Parent.VaultAnimation)
	print("Animation has been played")
end)

Any answer is appreciated!

2 answers

✓ Accepted answer

you forgot the play at the end

script.Parent.VaultEvent.OnClientEvent:Connect(function(player)
    script.Parent:FindFirstChild("Humanoid"):LoadAnimation(script.Parent.VaultAnimation):Play()
    print("Animation has been played")
end)

1 comment

0

I guess my brain shut off. Thanks for th reply!

you forgot to play the animation after creating the animation track you should play it like this:

script.Parent.VaultEvent.OnClientEvent:Connect(function(player)
   local AnimTrack = script.Parent:FindFirstChild("Humanoid"):LoadAnimation(script.Parent.VaultAnimation)
AnimTrack:Play()
    print("Animation has been played")
end)

This discussion is preserved as it was. New answers, comments, and votes are closed.