Ive created a walking animation for a rigged character and i want it to work for everybody however once somebody else starts to walk they t-pose after a second
this is the animation script
‘’‘’
print(“1”)
local Player = game.Players.LocalPlayer
local character = Player.Character or Player.CharacterAdded:Wait()
local Idle = Instance.new(“Animation”)
Idle.AnimationId = “rbxassetid://13779417516”
local Walk = Instance.new(“Animation”)
Walk.AnimationId = “rbxassetid://13779407582”
repeat task.wait() until script:FindFirstChildWhichIsA(“Animation”)
print(“2”)
local idleAnim = script.Parent.Humanoid.Animator:LoadAnimation(Idle)
idleAnim.Looped = true
idleAnim.Priority = Enum.AnimationPriority.Idle
local runAnim = script.Parent.Humanoid.Animator:LoadAnimation(Walk)
runAnim.Looped = true
runAnim.Priority = Enum.AnimationPriority.Movement
local jumpAnim = script.Parent.Humanoid.Animator:LoadAnimation(Idle)
jumpAnim.Looped = true
jumpAnim.Priority = Enum.AnimationPriority.Idle
local climbAnim = script.Parent.Humanoid.Animator:LoadAnimation(Walk)
climbAnim.Looped = true
climbAnim.Priority = Enum.AnimationPriority.Movement
local fallAnim = script.Parent.Humanoid.Animator:LoadAnimation(Idle)
fallAnim.Looped = true
fallAnim.Priority = Enum.AnimationPriority.Idle
local swimAnim = script.Parent.Humanoid.Animator:LoadAnimation(Walk)
swimAnim.Looped = true
swimAnim.Priority = Enum.AnimationPriority.Movement
local sitAnim = script.Parent.Humanoid.Animator:LoadAnimation(Idle)
sitAnim.Looped = true
sitAnim.Priority = Enum.AnimationPriority.Idle
local coreAnim = script.Parent.Humanoid.Animator:LoadAnimation(Idle)
coreAnim.Looped = true
coreAnim.Priority = Enum.AnimationPriority.Core
print(“3”)
game[“Run Service”].Heartbeat:Connect(function()
if script.Parent.HumanoidRootPart.Velocity.Magnitude > 0.1 then
if script.Parent.Humanoid:GetState() == Enum.HumanoidStateType.Dead then
for _, i in script.Parent.Humanoid:GetPlayingAnimationTracks() do
i:Stop()
end
elseif script.Parent.Humanoid:GetState() == Enum.HumanoidStateType.Seated then
if not sitAnim.IsPlaying then
sitAnim:Play()
end
elseif script.Parent.Humanoid:GetState() == Enum.HumanoidStateType.Jumping then
if not jumpAnim.IsPlaying then
jumpAnim:Play()
end
elseif script.Parent.Humanoid:GetState() == Enum.HumanoidStateType.Climbing then
if not climbAnim.IsPlaying then
climbAnim:Play()
end
elseif script.Parent.Humanoid:GetState() == Enum.HumanoidStateType.Freefall then
if not fallAnim.IsPlaying then
fallAnim:Play()
end
elseif script.Parent.Humanoid:GetState() == Enum.HumanoidStateType.Swimming then
if not swimAnim.IsPlaying then
swimAnim:Play()
end
elseif script.Parent.Humanoid:GetState() == Enum.HumanoidStateType.Running then
if not runAnim.IsPlaying then
runAnim:Play()
end
end
else
for _, i in script.Parent.Humanoid:GetPlayingAnimationTracks() do
if i.Name ~= "Idle" then
i:Stop()
print("5")
end
end
if not idleAnim.IsPlaying then
idleAnim:Play()
print("4")
end
end
end)
I think that since the animation is run in a local script you would have to render the animation on the server for each player to see each others animations. I’m not sure if that is the solution, but that would be my best guess.
I made everything that uses the walk animation use a remote event and here is the script
local Walk = Instance.new(“Animation”)
Walk.AnimationId = “rbxassetid://13779407582”
game.ReplicatedStorage.Remotes.Run.OnServerEvent:Connect(function(Player)
print(Player.Name)
local character = Player.Character or Player.CharacterAdded:Wait()
local runAnim = Player.Character:WaitForChild(“Humanoid”).Animator:LoadAnimation(Walk)
runAnim:Play()
end)
yes when you say “FireServer” I would put the animation as a parameter to pass it to the server script and use the server to play the animation on the client so all players can see the animation
For Example
Local Script:
game.ReplicatedStorage.Remotes.Run:FireServer(Walk)
– Passing the animation to the Server
Server Script:
game.ReplicatedStorage.Remotes.Run.OnServerEvent:Connect(function(Player, walk)
– Play animation on the server so all players can see it
game.ReplicatedStorage.Remotes.Run.OnServerEvent:Connect(function(Player, Walk)
print(Player.Name)
local character = Player.Character or Player.CharacterAdded:Wait()
local runAnim = Player.Character:WaitForChild(“Humanoid”).Animator:LoadAnimation(Walk)
runAnim:Play()
end)
if script.Parent.HumanoidRootPart.Velocity.Magnitude > 0.1 then – the if statement detecting if it walks
if script.Parent.Humanoid:GetState() == Enum.HumanoidStateType.Dead then
for _, i in script.Parent.Humanoid:GetPlayingAnimationTracks() do
i:Stop()
end
elseif script.Parent.Humanoid:GetState() == Enum.HumanoidStateType.Seated then
if not sitAnim.IsPlaying then
sitAnim:Play()
run:FireServer(Walk)
end
elseif script.Parent.Humanoid:GetState() == Enum.HumanoidStateType.Jumping then
if not jumpAnim.IsPlaying then
jumpAnim:Play()
run:FireServer(Walk)
end
elseif script.Parent.Humanoid:GetState() == Enum.HumanoidStateType.Climbing then
if not climbAnim.IsPlaying then
climbAnim:Play()
run:FireServer(Walk)
end
elseif script.Parent.Humanoid:GetState() == Enum.HumanoidStateType.Freefall then
if not fallAnim.IsPlaying then
fallAnim:Play()
run:FireServer(Walk)
end
elseif script.Parent.Humanoid:GetState() == Enum.HumanoidStateType.Swimming then
if not swimAnim.IsPlaying then
swimAnim:Play()
run:FireServer(Walk)
end
elseif script.Parent.Humanoid:GetState() == Enum.HumanoidStateType.Running then
if not runAnim.IsPlaying then
runAnim:Play()
run:FireServer(Walk)
print(“fired”)
end
end
else
for _, i in script.Parent.Humanoid:GetPlayingAnimationTracks() do
if i.Name ~= “Idle” then
i:Stop()
end
end
if not idleAnim.IsPlaying then
idleAnim:Play()
game.ReplicatedStorage.Remotes.Idle:FireServer(Idle)
end
end
end)