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!
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)
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)