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

Is there a way to play my animation for only the player?

Asked by 4 years ago

I'm making a crouch script and it works fine for one player but if you have more, then any player can control the newest joined player. The animation will play only for this new player and nobody else. This is my script under ServerScriptService:

local walking = Instance.new("BoolValue")
walking.Value = false
local Players = game:GetService("Players")


Players.PlayerAdded:Connect(function(player)
    wait(4)

local Animation = Instance.new("Animation", player.Character)
  Animation.AnimationId = "rbxassetid://5010278985"
  Animate = player.Character.Humanoid:LoadAnimation(Animation)
wait()

local Animation2 = Instance.new("Animation", player.Character)
    Animation2.Name = "Animation2"
    Animation2.AnimationId = "rbxassetid://5062446283"
    Animate2 = player.Character.Humanoid:LoadAnimation(Animation2)

end)



game.ReplicatedStorage.Crouch.Start.OnServerEvent:Connect(function(player)
    if walking.Value == false then
        walking.Value = true
        Animate:Play()

    end
end)


game.ReplicatedStorage.Crouch.End.OnServerEvent:Connect(function(player)
    walking.Value = false
    Animate:Stop()
    Animate2:Stop()

end)


game.ReplicatedStorage.Crouch.Start.OnServerEvent:Connect(function(player)
player.Character.Humanoid.Running:Connect(function(speed)
    if walking.Value == true and speed >= 1 then
        Animate:Stop()
        Animate2:Play()

        end
    end)
end)


game.ReplicatedStorage.Crouch.Start.OnServerEvent:Connect(function(player)
player.Character.Humanoid.Running:Connect(function(speed)
            if speed <= 0 and walking.Value == true then 
                Animate2:Stop()
                Animate:Play()

        end
    end)
end)

Instead of Animate:Play() or Animate:Stop() using my created animations is there a way to do

player.Character.Animate:Play()

I've just recently got into animations so any help is appreciated.

3 answers

Log in to vote
1
Answered by 4 years ago
Edited 4 years ago

The problem is that the Animator instance on the humanoid automatically controls the synchronisation of your animation. You can try to create a different animator instance and attempt to load the animation onto that new animator instance. Note that you must do is on the client so that the animator instance won't replicate back to the server!

https://devforum.roblox.com/t/how-do-i-make-an-animation-just-play-on-the-client/76039/2

Ad
Log in to vote
0
Answered by
iivSnooxy 248 Moderation Voter
4 years ago

Oh I see your problem ServerScriptService - is for the whole server to see local - only you to see or you could choose someone else

If this helps please consider an upvote. Greatly Appreciated ????

0
The Animator instance on the humanoid enables automatic replication from both server sided animations and client-sided animations. This is not going to help. User#834 0 — 4y
0
Oh. iivSnooxy 248 — 4y
Log in to vote
0
Answered by
goodlead -62
4 years ago

I have seen someone on youtube make a n animation that plays using a plugin. I hope this helps???

Answer this question