Wall Climbing System not working [SOLVED]

I am making a wall climbing system and I have gotten it to a point where I have no clue how to fix it. Basically right now it is able to detect when there is a climbable wall, and it can change the state of the humanoid, the problem is that it flicks the player to the climbing state, but instantly switches it back to the running state, and I am unsure how to fix this.

-- ServerScriptService - WallClimbServerScript

local WallClimbEvent = game:GetService("ReplicatedStorage").Events.WallClimbEvent

local climbingPlayers = {}

WallClimbEvent.OnServerEvent:Connect(function(player)
	local character = player.Character
	if character then
		local humanoid = character:WaitForChild("Humanoid")

		local function checkIfClimbable(part)
			return part:IsA("BasePart") and part:GetAttribute("Climbable")
		end

		local rootPart = character:WaitForChild("HumanoidRootPart")
		rootPart.Touched:Connect(function(touchedPart)
			if checkIfClimbable(touchedPart) then
				humanoid:ChangeState(Enum.HumanoidStateType.Climbing)
				climbingPlayers[player.UserId] = true -- Track climbing state

				humanoid:SetStateEnabled(Enum.HumanoidStateType.Running, false) -- Disable running
			end
		end)

		humanoid.StateChanged:Connect(function(_, newState)
			if newState == Enum.HumanoidStateType.Climbing then
				climbingPlayers[player.UserId] = true -- Track climbing state
				humanoid:SetStateEnabled(Enum.HumanoidStateType.Running, false) -- Disable running
			else
				climbingPlayers[player.UserId] = nil -- Reset climbing state
				humanoid:SetStateEnabled(Enum.HumanoidStateType.Running, true) -- Re-enable running
			end
		end)
	end
end)

game.Players.PlayerRemoving:Connect(function(player)
	climbingPlayers[player.UserId] = nil -- Clear climbing state when player leaves
end)

There is no need at all to run this on the serverside, this should be in a LocalScript. The culprit could also be that the remotes are being spammed too fast and passing the 50KB/s limit. Even if you were able to go below that, it would kill your server performance. Revert this to work on a LocalScript and let me know if you still need help after.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.