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

[PLS HELP] Animation wont play and theres no error?

Asked by 6 years ago
game.ReplicatedStorage.AnimationPlayEvent.OnServerEvent:Connect(function(player, animationID)

    local Animation = Instance.new("Animation")
    Animation.AnimationId = "http://www.roblox.com/Asset?ID="..animationID

    local LoadAnimation = workspace[player.Name].Humanoid:LoadAnimation(Animation)
    LoadAnimation:Play()
    print("Played")

    game.ReplicatedStorage.UnequipAnimationEvent.OnServerEvent:Connect(function(player, animationID)

        LoadAnimation:Stop()
        print("Stopped")

    end)
end)

game.ReplicatedStorage.GlockAnimationEvent.OnServerEvent:Connect(function(player, animationID1)

    local Animation = Instance.new("Animation")
    Animation.AnimationId = "http://www.roblox.com/Asset?ID="..animationID1

    local LoadAnimation = workspace[player.Name].Humanoid:LoadAnimation(Animation)
    LoadAnimation:Play()
    print("Played")

    game.ReplicatedStorage.HoldAnimationEvent.OnServerEvent:Connect(function(player, animationID1)

        LoadAnimation:Stop()
        print("Stopped")

        local NewAnimation = Instance.new("Animation")
        NewAnimation.AnimationId = "http://www.roblox.com/Asset?ID="..animationID1

        local LoadNewAnimation = workspace[player.Name].Humanoid:LoadAnimation(NewAnimation)
        LoadNewAnimation:Play()
        print("Played")

        game.ReplicatedStorage.UnequipAnimationEvent.OnServerEvent:Connect(function(player, animationID1)

            LoadNewAnimation:Stop()
            print("Stopped")

        end)
    end)
end)

game.ReplicatedStorage.M1911AnimationEvent.OnServerEvent:Connect(function(player, animationID2)

    local Animation = Instance.new("Animation")
    Animation.AnimationId = "http://www.roblox.com/Asset?ID="..animationID2

    local LoadAnimation = workspace[player.Name].Humanoid:LoadAnimation(Animation)
    LoadAnimation:Play()
    print("Played")

    game.ReplicatedStorage.HoldAnimationEvent.OnServerEvent:Connect(function(player, animationID2)

        LoadAnimation:Stop()
        print("Stopped")

        local NewAnimation = Instance.new("Animation")
        NewAnimation.AnimationId = "http://www.roblox.com/Asset?ID="..animationID2

        local LoadNewAnimation = workspace[player.Name].Humanoid:LoadAnimation(NewAnimation)
        LoadNewAnimation:Play()
        print("Played")

        game.ReplicatedStorage.UnequipAnimationEvent.OnServerEvent:Connect(function(player, animationID2)

            LoadNewAnimation:Stop()
            print("Stopped")

        end)
    end)
end)

This is my OnServerEvent script (In workspace) . I have 1 baton and 2 guns, 1 is named "Glock" and another is named "M1911". I was trying to make it so that when the baton or either of the 2 guns is equipped, it fires a RemoteEvent which plays the animation.

But no matter what, it wont play the animation although it prints "Played" or "Stopped" in the output. I pressed f9 to check for error but theres none (in both Actual game and studio) .

Here are the fire RemoteEvent scripts for baton, and the 2 guns.

Baton Script:

local tool = script.Parent

tool.Equipped:Connect(function()

    wait()
    game.ReplicatedStorage.AnimationPlayEvent:FireServer("2639159960")
    print("Equip Animation Fired")

end)

tool.Unequipped:Connect(function()

    wait()
    game.ReplicatedStorage.UnequipAnimationEvent:FireServer()
    print("Unequip Animation Fired")

end)

Glock Script:

local tool = script.Parent

tool.Equipped:Connect(function()

    wait()
    game.ReplicatedStorage.GlockAnimationEvent:FireServer("02640284714")
    print("Glock Equip Event Fired")
    wait()
    game.ReplicatedStorage.HoldAnimationEvent:FireServer("02640561642")
    print("Hold Animation Event Fired")

end)

tool.Unequipped:Connect(function()

    wait()
    game.ReplicatedStorage.UnequipAnimationEvent:FireServer()
    print("Unequip Animation Fired")

end)

M1911 Script:

local tool = script.Parent

tool.Equipped:Connect(function()

    wait()
    game.ReplicatedStorage.M1911AnimationEvent:FireServer("02640284714")
    print("M1911 Equip Animation Fired")
    wait()
    game.ReplicatedStorage.HoldAnimationEvent:FireServer("02640561642")
    print("Hold Animation Fired")

end)

tool.Unequipped:Connect(function()

    wait()
    game.ReplicatedStorage.UnequipAnimationEvent:FireServer()
    print("Unequip Animation Fired")

end)
0
You can play animations on the client since client movement is replicated. No need to over complicate. EpicMetatableMoment 1444 — 6y
0
How do i do that? Yokohane 50 — 6y
0
Can u write an answer for that?? Appreciated, will accept answer if problem solved, anyway, thanks for ur comment :) Yokohane 50 — 6y

Answer this question