Animate script stops working after ANY animation is played

I found an animate script that supposedly was the one from a while ago. I’m using that because it would fit well with the retro style of my game, but whenever I play an animation, the animate script still works perfectly fine on the client, but other clients can’t see the movement. The “animations” from the script arent actualy animations, they move the limbs with setting the angles and shoulders

https://gyazo.com/5ce19f4fe24565ed40f576b41cdd9b7f

function waitForChild(parent, childName)
	local child = parent:findFirstChild(childName)
	if child then return child end
	while true do
		child = parent.ChildAdded:wait()
		if child.Name==childName then return child end
	end
end

-- ANIMATION

-- declarations

local Figure = script.Parent
local Torso = waitForChild(Figure, "Torso")
local RightShoulder = waitForChild(Torso, "Right Shoulder")
local LeftShoulder = waitForChild(Torso, "Left Shoulder")
local RightHip = waitForChild(Torso, "Right Hip")
local LeftHip = waitForChild(Torso, "Left Hip")
local Neck = waitForChild(Torso, "Neck")
local Humanoid = waitForChild(Figure, "Humanoid")
local pose = "Standing"

local toolAnim = "None"
local toolAnimTime = 0

local jumpMaxLimbVelocity = 0.75

-- functions

function onRunning(speed)
	if speed>0 then
		pose = "Running"
	else
		pose = "Standing"
	end
end

function onDied()
	pose = "Dead"
end

function onJumping()
	pose = "Jumping"
end

function onClimbing()
	pose = "Climbing"
end

function onGettingUp()
	pose = "GettingUp"
end

function onFreeFall()
	pose = "FreeFall"
end

function onFallingDown()
	pose = "FallingDown"
end

function onSeated()
	pose = "Seated"
end

function onPlatformStanding()
	pose = "PlatformStanding"
end

function onSwimming(speed)
	if speed>0 then
		pose = "Running"
	else
		pose = "Standing"
	end
end

function moveJump()
	RightShoulder.MaxVelocity = jumpMaxLimbVelocity
	LeftShoulder.MaxVelocity = jumpMaxLimbVelocity
  RightShoulder:SetDesiredAngle(3.14)
	LeftShoulder:SetDesiredAngle(-3.14)
	RightHip:SetDesiredAngle(0)
	LeftHip:SetDesiredAngle(0)
end


-- same as jump for now

function moveFreeFall()
	RightShoulder.MaxVelocity = jumpMaxLimbVelocity
	LeftShoulder.MaxVelocity = jumpMaxLimbVelocity
	RightShoulder:SetDesiredAngle(3.14)
	LeftShoulder:SetDesiredAngle(-3.14)
	RightHip:SetDesiredAngle(0)
	LeftHip:SetDesiredAngle(0)
end

function moveSit()
	RightShoulder.MaxVelocity = 0.15
	LeftShoulder.MaxVelocity = 0.15
	RightShoulder:SetDesiredAngle(3.14 /2)
	LeftShoulder:SetDesiredAngle(-3.14 /2)
	RightHip:SetDesiredAngle(3.14 /2)
	LeftHip:SetDesiredAngle(-3.14 /2)
end

function getTool()	
	for _, kid in ipairs(Figure:GetChildren()) do
		if kid.className == "Tool" then return kid end
	end
	return nil
end

function getToolAnim(tool)
	for _, c in ipairs(tool:GetChildren()) do
		if c.Name == "toolanim" and c.className == "StringValue" then
			return c
		end
	end
	return nil
end

function animateTool()
	
	if (toolAnim == "None") then
		RightShoulder:SetDesiredAngle(1.57)
		return
	end

	if (toolAnim == "Slash") then
		RightShoulder.MaxVelocity = 0.5
		RightShoulder:SetDesiredAngle(0)
		return
	end

	if (toolAnim == "Lunge") then
		RightShoulder.MaxVelocity = 0.5
		LeftShoulder.MaxVelocity = 0.5
		RightHip.MaxVelocity = 0.5
		LeftHip.MaxVelocity = 0.5
		RightShoulder:SetDesiredAngle(1.57)
		LeftShoulder:SetDesiredAngle(1.0)
		RightHip:SetDesiredAngle(1.57)
		LeftHip:SetDesiredAngle(1.0)
		return
	end
end

function move(time)
	local amplitude
	local frequency
  
	if (pose == "Jumping") then
		moveJump()
		return
	end

	if (pose == "FreeFall") then
		moveFreeFall()
		return
	end
 
	if (pose == "Seated") then
		moveSit()
		return
	end

	local climbFudge = 0
	
	if (pose == "Running") then
    if (RightShoulder.CurrentAngle > 1.5 or RightShoulder.CurrentAngle < -1.5) then
			RightShoulder.MaxVelocity = jumpMaxLimbVelocity
		else			
			RightShoulder.MaxVelocity = 0.15
		end
		if (LeftShoulder.CurrentAngle > 1.5 or LeftShoulder.CurrentAngle < -1.5) then
			LeftShoulder.MaxVelocity = jumpMaxLimbVelocity
		else			
			LeftShoulder.MaxVelocity = 0.15
		end
		amplitude = 1
		frequency = 9
	elseif (pose == "Climbing") then
		RightShoulder.MaxVelocity = 0.5 
		LeftShoulder.MaxVelocity = 0.5
		amplitude = 1
		frequency = 9
		climbFudge = 3.14
	else
		amplitude = 0.1
		frequency = 1
	end

	desiredAngle = amplitude * math.sin(time*frequency)

	RightShoulder:SetDesiredAngle(desiredAngle + climbFudge)
	LeftShoulder:SetDesiredAngle(desiredAngle - climbFudge)
	RightHip:SetDesiredAngle(-desiredAngle)
	LeftHip:SetDesiredAngle(-desiredAngle)


	local tool = getTool()

	if tool then
	
		animStringValueObject = getToolAnim(tool)

		if animStringValueObject then
			toolAnim = animStringValueObject.Value
			-- message recieved, delete StringValue
			animStringValueObject.Parent = nil
			toolAnimTime = time + .3
		end

		if time > toolAnimTime then
			toolAnimTime = 0
			toolAnim = "None"
		end

		animateTool()

		
	else
		toolAnim = "None"
		toolAnimTime = 0
	end
end


-- connect events

Humanoid.Died:connect(onDied)
Humanoid.Running:connect(onRunning)
Humanoid.Jumping:connect(onJumping)
Humanoid.Climbing:connect(onClimbing)
Humanoid.GettingUp:connect(onGettingUp)
Humanoid.FreeFalling:connect(onFreeFall)
Humanoid.FallingDown:connect(onFallingDown)
Humanoid.Seated:connect(onSeated)
Humanoid.PlatformStanding:connect(onPlatformStanding)
Humanoid.Swimming:connect(onSwimming)
-- main program

local runService = game:service("RunService");

while Figure.Parent~=nil do
	local _, time = wait(0.1)
	move(time)
end

1 Like

(Thats the animate script)
yaaaaaa

1 Like

It sounds like the issue you are experiencing is that the animations are not syncing across clients. This is likely because you are only modifying the angles of the parts on the client that is running the script, and these changes are not being replicated to the other clients.

To fix this, you can use the ReplicatedStorage service to store and replicate the values for the desired angles of the parts to all of the clients. You can then read these values on each client and set the desired angles of the parts accordingly.

Here is an example of how you could modify your script to replicate the values

-- Declare ReplicatedStorage variables
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local RightShoulderAngle = ReplicatedStorage:WaitForChild("RightShoulderAngle")
local LeftShoulderAngle = ReplicatedStorage:WaitForChild("LeftShoulderAngle")
local RightHipAngle = ReplicatedStorage:WaitForChild("RightHipAngle")
local LeftHipAngle = ReplicatedStorage:WaitForChild("LeftHipAngle")

-- Set the initial values of the ReplicatedStorage variables
RightShoulderAngle.Value = 1.57
LeftShoulderAngle.Value = -1.57
RightHipAngle.Value = 0
LeftHipAngle.Value = 0

-- Set the desired angles of the parts to the replicated values
RightShoulder:SetDesiredAngle(RightShoulderAngle.Value)
LeftShoulder:SetDesiredAngle(LeftShoulderAngle.Value)
RightHip:SetDesiredAngle(RightHipAngle.Value)
LeftHip:SetDesiredAngle(LeftHipAngle.Value)

-- Update the replicated values when the desired angles of the parts are changed
function updateAngles(part, angle)
	if part == "RightShoulder" then
		RightShoulderAngle.Value = angle
	elseif part == "LeftShoulder" then
		LeftShoulderAngle.Value = angle
	elseif part == "RightHip" then
		RightHipAngle.Value = angle
	elseif part == "LeftHip" then
		LeftHipAngle.Value = angle
	end
end

-- Update the desired angles of the parts when the replicated values are changed
RightShoulderAngle.Changed:Connect(function()
	RightShoulder:SetDesiredAngle(RightShoulderAngle.Value)
end)
LeftShoulderAngle.Changed:Connect(function()
	LeftShoulder:SetDesiredAngle(LeftShoulderAngle.Value)
end)
RightHipAngle.Changed:Connect(function()
	RightHip:SetDesiredAngle(RightHipAngle.Value)
end)
LeftHipAngle.Changed:Connect(function()
	LeftHip:SetDesiredAngle(LeftHipAngle.Value)
end)

-- Replace calls to SetDesiredAngle with calls to updateAngles
function moveJump()
	updateAngles("RightShoulder", 3.14)
	updateAngles("LeftShoulder", -3.14)
	updateAngles("RightHip", 0)
	updateAngles("LeftHip", 0)
end

function moveFreeFall()
	updateAngles("RightSh
1 Like

How are they being replicated to the other clients?

1 Like

In Roblox, ReplicatedStorage is a special service that is used to store objects (such as the RightShoulderAngle, LeftShoulderAngle, RightHipAngle, and LeftHipAngle variables) that should be replicated to all clients connected to a game. When the value of one of these variables is changed on the server, it is automatically replicated to all the clients, so that all clients see the same value.

The ReplicatedStorage service is typically used to store things like player data, game modes, and other global variables that need to be shared between the server and clients.

In this script, the RightShoulderAngle, LeftShoulderAngle, RightHipAngle, and LeftHipAngle variables are being used to store the angles of the corresponding parts. When the desired angles of these parts are changed on the server, the updateAngles function is called to update the values of these variables. This causes the new values to be replicated to all the clients, so that all clients see the same angles for these parts.

1 Like

The thing is though, that the script works perfectly fine (all other players can see the limbs moving) but whenever an animation is played (ex: running animation or swinging animation) on the player, right after the animation is stopped, the script only replicates the animation of the limbs on the local client, not others.