50/50 Chance of animation not working

  1. What do you want to achieve? A working animation.

  2. What is the issue? Sometimes the animation works sometimes it doesnt and all i get is the roblox default idle animation.

  3. What solutions have you tried so far? Adding print() to see if it runs, it does it just doesnt remove the default animation.

local Character = script.Parent

local Humanoid = Character:WaitForChild("Humanoid")

local Torso = Character:WaitForChild("Torso")

local RightShoulder = Torso:WaitForChild("Right Shoulder")
local LeftShoulder = Torso:WaitForChild("Left Shoulder")

local RightHip = Torso:WaitForChild("Right Hip")
local LeftHip = Torso:WaitForChild("Left Hip")

local Neck = Torso:WaitForChild("Neck")

local Pose = "Standing"

Character:WaitForChild("Animate"):Destroy()

Humanoid.Running:Connect(function(Speed)
	if Speed > 0 and Humanoid.MoveDirection.Magnitude > 0 then
		Pose = "Running"
	else
		Pose = "Standing"
	end
end)

Humanoid.Died:Connect(function()
	Pose = "Dead"
end)

Humanoid.Jumping:Connect(function()
	Pose = "Jumping"
end)

Humanoid.Climbing:Connect(function()
	Pose = "Climbing"
end)

Humanoid.GettingUp:Connect(function()
	Pose = "GettingUp"
end)

Humanoid.FreeFalling:Connect(function()
	Pose = "FreeFall"
end)

Humanoid.FallingDown:Connect(function()
	Pose = "FallingDown"
end)

Humanoid.Seated:Connect(function()
	Pose = "Seated"
end)

Humanoid.PlatformStanding:Connect(function()
	Pose = "PlatformStanding"
end)

local function JumpOrFreeFall()
	RightShoulder.MaxVelocity = 0.5
	RightShoulder.DesiredAngle = 3.14
	
	LeftShoulder.MaxVelocity = 0.5
	LeftShoulder.DesiredAngle = -3.14
	
	RightHip.DesiredAngle = 0
	LeftHip.DesiredAngle = 0
end

local function Move(Time)
	local Amplitude = 0
	local Frequency = 0
	local ClimbFudge = 0
	
	if Pose == "Jumping" then
		JumpOrFreeFall()
		
		return
	end
	
	if Pose == "FreeFall" then
		JumpOrFreeFall()

		return
	end
	
	if Pose == "Seated" then
		RightShoulder.MaxVelocity = 0.15
		RightShoulder.DesiredAngle = 3.14/2

		LeftShoulder.MaxVelocity = 0.15
		LeftShoulder.DesiredAngle = -3.14/2

		RightHip.DesiredAngle = 3.14/2
		LeftHip.DesiredAngle = -3.14/2

		return
	end
	
	if Pose == "Running" then
		RightShoulder.MaxVelocity = 0.15
		LeftShoulder.MaxVelocity = 0.15
		
		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
		Frequency = 0
	end
	
	local DesiredAngle = Amplitude * math.sin(Time * Frequency)
	
	if Character:FindFirstChildWhichIsA("Tool") and Pose ~= "Climbing" then
		RightShoulder.MaxVelocity = 0.15
		RightShoulder.DesiredAngle = 3.14/2
		
		LeftShoulder.DesiredAngle = DesiredAngle - ClimbFudge

		RightHip.DesiredAngle = -DesiredAngle
		LeftHip.DesiredAngle = -DesiredAngle
	else
		RightShoulder.DesiredAngle = DesiredAngle + ClimbFudge
		LeftShoulder.DesiredAngle = DesiredAngle - ClimbFudge

		RightHip.DesiredAngle = -DesiredAngle
		LeftHip.DesiredAngle = -DesiredAngle
	end
end

while Character ~= nil do
	local _, Time = wait(0.1)
	
	Move(Time)
end

2 Likes

Following for debug:

  • pcall/xpcall
  • print() statements to visualise where the script is reaching
  • don’t use wait use task.wait() :wink:

What’s the goal with this? lol
Your using a function (wait(0.1)) that returns NOTHING (nil) and setting it to _ and then parsing Time which is nil


I would personally replace:

while Character ~= nil do
	local _, Time = wait(0.1)
	
	Move(Time)
end

With:

game:GetService('RunService').Heartbeat:Connect(function(delta)
if Character then
      local Time = 0.1
     Move(Time)
end     
task.wait(tick() * delta)
end)
1 Like

That isnt the issue im talking about, if you watch the video i included you should have noticed i was stuck in the idle animation but if you look closely its the default r6 animation idle not the custom one i created. So the issue is most likely removing the default animation which i did in line 19.

Forgot to mention that ur version of my script doesnt really work.