so I have this system for crouching in a game I’m working on but the animation only works for client so other players cannot see the player doing the action, what could be the problem?
Thanks in advance.
Code below is in a local script inside StarterCharacterScripts:
local userinputservice = game:GetService("UserInputService")
local charecter = script.Parent
local humanoid = charecter:WaitForChild("Humanoid")
local crouchlanm = humanoid:LoadAnimation(script:WaitForChild("Crouch Walking"))
local isCrouching = false
-------------------------------------------------------------------------------
-------------------------------------------------------------------------------
userinputservice.InputBegan:Connect(function(input)
if input.KeyCode == Enum.KeyCode.LeftControl then
if not isCrouching then -- if not already crouched then do this
isCrouching = true
crouchlanm:Play(0.25)
humanoid.WalkSpeed = 6
humanoid.JumpPower = 0
else -- if already crouching then do this
isCrouching = false
crouchlanm:Stop(0.25)
humanoid.WalkSpeed = 12
humanoid.JumpPower = 50
end
end
end)
-------------------------------------------------------------------------------
-------------------------------------------------------------------------------
humanoid.Running:Connect(function(speed)
if isCrouching == true then
if speed > 0 then -- if is moving then
crouchlanm:AdjustSpeed(1)
else
crouchlanm:AdjustSpeed(0)
end
end
end)
I have it working on local rn but the thing is I have 2 animations, an idle crouch, and a moving crouch, the moving one works fine but the idle one just looks like your standing as it shows below
I fixed it, i just had to put an animator object inside the humanoid of the player, i did it from the workspace as i had a custom character but you can do it with a script too, this is my local script in StarterCharacterScripts:
local userinputservice = game:GetService("UserInputService")
local charecter = script.Parent
local humanoid = charecter:WaitForChild("Humanoid")
local crouchlanm = humanoid:LoadAnimation(script:WaitForChild("Crouch Walking"))
local StopAnimation = humanoid:LoadAnimation(script:WaitForChild("Crouch Walk Idle"))
local isCrouching = false
-------------------------------------------------------------------------------
-------------------------------------------------------------------------------
userinputservice.InputBegan:Connect(function(input)
if input.KeyCode == Enum.KeyCode.LeftControl then
if not isCrouching then -- if not already crouched then do this
isCrouching = true
StopAnimation:Play(0.25)
humanoid.WalkSpeed = 6
humanoid.JumpPower = 0
else -- if already crouching then do this
isCrouching = false
crouchlanm:Stop(0.25)
StopAnimation:Stop(0.25)
humanoid.WalkSpeed = 12
humanoid.JumpPower = 50
end
end
end)
-------------------------------------------------------------------------------
-------------------------------------------------------------------------------
humanoid.Running:Connect(function(speed)
if isCrouching == true then
if speed > 0 then -- if is moving then\
StopAnimation:Stop(0.25)
crouchlanm:Play(0.25)
else -- if is no longer moving then
crouchlanm:Stop(0.25)
StopAnimation:Play(0.25)
end
end
end)