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 4 years ago
Edited 4 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 — 4y
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 — 4y

1 answer

Log in to vote
1
Answered by
Elixcore 1337 Moderation Voter
4 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 — 4y
0
== Azarth 3141 — 4y
Ad

Answer this question