Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Why isn't my animation playing?

Asked by 5 years ago
Edited 5 years ago

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)
0
Try using remote events so the animation can be seen by other clients (players). ScaleisRed 58 — 5y
1
Scale, when the client plays animations it will replicate to the server (the client has network ownership over the client's character) bhqpping 80 — 5y

1 answer

Log in to vote
1
Answered by
Elixcore 1337 Moderation Voter
5 years ago

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)
0
Thanks! marioman1932 48 — 5y
0
== Azarth 3141 — 5y
Ad

Answer this question