How do I play the climbing animation when a player is climbing up the stairs?

Hello World!

So I am currently recreating the 2007 Roblox Client in Roblox Studio and I am currently bewildered on how to play the climbing animation when a player is climbing up the stairs?

Here is a simple depiction of what I am saying.

  • Old Roblox climb animation plays when climbs up stairs

Thanks in advance!

1 Like

this:

game.Players.Humanoid.Climbing:Connect(function(speed)
	print("climbing at "..tostring(speed))
end)

Sorry, but this doesn’t work. The Humanoid should be climbing when it’s going up stairs.

It’s impossible to catch if the player climbing the stairs 100%
Put i have the solution:

game.Players.PlayerAdded:Connect(function(plr)
	plr.CharacterAdded:Connect(function(chr)
		local oldPos = nil
		local delta = DateTime.now() --Wait function
		local connection
		local onceClimbing = false
		local climbing = false
		local countdown = 300 -- If you want change the countdown, you'll have to calculate all distances.
		connection = game:GetService("RunService").Heartbeat:Connect(function()
			if chr == nil then connection:Disconnect() end
			if DateTime.now().UnixTimestampMillis-delta.UnixTimestampMillis>countdown then
				if oldPos~=nil then
					local distance = math.abs(chr.HumanoidRootPart.Position.Y-oldPos.Y)
					local a,b,c,d = 0.011073589324951172*chr.Humanoid.WalkSpeed --The distance must be higher than
					               ,0.012495402145385743*chr.Humanoid.WalkSpeed --The distance must be lower than
					               ,0.007411089324951172*chr.Humanoid.WalkSpeed --The distance must be higher than
					               ,0.007870402145385742*chr.Humanoid.WalkSpeed --The distance must be lower than
					if distance > a and distance < b then
						onceClimbing =  true
						climbing = true
						chr.UpperTorso.BrickColor = BrickColor.Green()
                        --Put your code when the player climbing
					else
						if onceClimbing == true then --Because i view that 1/2 verification, when climbing, the distance is low.
							if distance > c and distance < d then
								climbing = true
								chr.UpperTorso.BrickColor = BrickColor.Green()
                                --Put your code when the player climbing
							else
								climbing = false
								chr.UpperTorso.BrickColor = BrickColor.Red()
                                --Put your code when the player has finish to climbing
							end
							onceClimbing = false
						else
							climbing = false
							chr.UpperTorso.BrickColor = BrickColor.Red()
                            --Put your code when the player not climbing
						end
					end
				end
				delta = DateTime.now() --Refresh for the wait Function
			end
			oldPos = chr.HumanoidRootPart.Position
		end)
	end)
end)

Result ( In this footage, i was unlucky ):

Let me try it out. I’ll reply if it works. Thanks.

I have more explains in the edited code.
I have delete a condition because it’s is useless.
And i explains more, where put your code

It kinda works, but I don’t think this will work enough in my opinion. Sorry.
I modified the code to experiment with it.

I’ll give you it.

function ControlModule:Climbing_Up_Stairs()
	local quick_climb = false
	local climbing = false
	
	if self._Old_Position ~= nil then
		local dist = Mathf.Abs(HumanoidRootPart.Position.Y - self._Old_Position.Y)
		
		local test_1 = 0.001073589324951172 * Humanoid.WalkSpeed
		local test_2 = Humanoid.WalkSpeed
		local test_3 = 0.007411089324951172 * Humanoid.WalkSpeed
		local test_4 = 0.007870402145385742 * Humanoid.WalkSpeed
		
		if dist > test_1 and dist < test_2 then
			quick_climb = true
			climbing = true
			
			Humanoid:ChangeState(Enum.HumanoidStateType.Climbing)
		elseif quick_climb then
			if dist > test_3 and dist < test_4 then
				climbing = true
				
				Humanoid:ChangeState(Enum.HumanoidStateType.Climbing)
			else
				climbing = false
			end
			
			quick_climb = false
		elseif not quick_climb then
			climbing = false
		end
	end
	
	self._Old_Position = HumanoidRootPart.Position
end