I have an animation and i want the player to play it once E is pressed.

LocalScript:

ocal UserInputService = game:GetService("UserInputService")
local E_Key = Enum.KeyCode.E
local WaitForAnimation = script:WaitForChild("Animation")
local Humanoid = game.Players.LocalPlayer.Character:WaitForChild("Humanoid")
local Animation = Humanoid:LoadAnimation(WaitForAnimation)

UserInputService.InputBegan:Connect(function(input, gameProcessedEvent)
	if (input.KeyCode == E_Key) then
		Animation:Play()
	end
end)

I know that the function is working but the animation isn't playing. I already tried with RemoteEvents and it just printed something. Can anyone explain what is wrong with the code?

P.S.: The code is perfectly fine, tried with an npc and it worked, but not with players.

4 comments

0

Are there any errors?

0

it works perfectly fine. i've tested it. what do you see here wrong?

0

The animation don't play.

0

you can try setting the track.Priority = 1