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

Why isn't my animation playing?

I was trying to play an animation inside the player, but it didn't work and there's no errors. Please help! Here is the script I used.

Local Script

local player = game.Players.LocalPlayer
local char = player.Character or player.CharacterAdded:Wait()
local uis = game:GetService("UserInputService")

uis.InputBegan:Connect(function(key)
	if key = Enum.KeyCode.E then
	script.AnimationController:LoadAnimation(script.Animation):Play()
	end
end)

2 comments

0

Try using remote events so the animation can be seen by other clients (players).

1

Scale, when the client plays animations it will replicate to the server (the client has network ownership over the client's character)

1 answer

✓ Accepted answer

Instead of an animationcontroller you should simply use the humanoid's LoadAnimation function and also please set the animation to a variable to allow it time to load.

also you need to do key.KeyCode, not key

local player = game.Players.LocalPlayer
local char = player.Character or player.CharacterAdded:Wait()
local uis = game:GetService("UserInputService")
local anim = char:WaitForChild("Humanoid"):LoadAnimation(script.Animation)

uis.InputBegan:Connect(function(key)
    if key.KeyCode = Enum.KeyCode.E then
    	anim:Play()
    end
end)

2 comments

0

Thanks!

0

==

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