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

Animation in LocalScript not start. How to solve?

Asked by 3 years ago

Hi, I've a problem with animations. I've created a LocalScript that if a RemoteEvent is invoked it will start an animation. This is the script:

repeat wait() until game:GetService("Players").LocalPlayer
local Player = script.Parent.Parent

game:GetService("ReplicatedStorage").StartAnimationEvent.OnClientEvent:Connect(function(AnimationName)
    local Humanoid = Player.Character:FindFirstChildOfClass("Humanoid")
    if Humanoid then
        local Animation = Humanoid:FindFirstChild(AnimationName)
        if Animation then
            local AnimationTrack = Humanoid:LoadAnimation(Animation)
            AnimationTrack:Play()
            AnimationTrack.Looped = true
            if AnimationTrack.IsPlaying then
                print("Is playing.")
            end
        end
    end
end)

However even if it is printed "Is playing.", which makes me understand that everything is ok the animation does not start.

0
With A Key or A Button Gui Or Something? TheStevenYt7758 28 — 3y
0
A command in the chat. Marko97_IT 2 — 3y

Answer this question