Rendering is paused for debugging while trying to change humanoid walk speed

The problem is on the line 47 (humanoid.WalkSpeed = “run”). When the shift is pressed the game stops rendering and I get Call stack “message”, and I don’t even know what that means. Output doesn’t tell me anything about it.

local UserInputService = game:GetService("UserInputService")

local Player = script.Parent
local humanoid = Player:WaitForChild("Humanoid")

--load animations--
local animation = Instance.new("Animation")
animation.AnimationId = "rbxassetid://5450777900"
local walkAnim = humanoid:LoadAnimation(animation)

local animation = Instance.new("Animation")
animation.AnimationId = "rbxassetid://4593960224"
local trotAnim = humanoid:LoadAnimation(animation)

local animation = Instance.new("Animation")
animation.AnimationId = "rbxassetid://4576387446"
local runAnim = humanoid:LoadAnimation(animation)

--modes and velocity--
local mode = "walk"
local BMod = "walk"
local BVel = 3
local anim = walkAnim
local BAnim = walkAnim

--functions--
UserInputService.InputBegan:Connect(function(key)
	if key.KeyCode == Enum.KeyCode.LeftControl then	--toggle trotting
		if mode == "walk" then
			mode = "trot"
			humanoid.WalkSpeed = 15
			anim = trotAnim
			BAnim = trotAnim
			BVel = 15
			BMod = "trot"
		else
			mode = "walk"
			humanoid.WalkSpeed = 3
			anim = walkAnim
			BAnim = walkAnim
			BVel = 3
			BMod = "walk"
		end
	elseif key.KeyCode == Enum.KeyCode.LeftShift then 	--toggle running
		if mode ~= "run" then
			mode = "run"
			humanoid.WalkSpeed = 20
			anim = runAnim
		else
			mode = BMod
			humanoid.WalkSpeed = BVel
			anim = BAnim 
		end
	end
	if key.KeyCode == Enum.KeyCode.W then
		anim:Play()
	end
end)

UserInputService.InputEnded:Connect(function(key)
	if key.KeyCode == Enum.KeyCode.W then
		local ActiveTracks = humanoid:GetPlayingAnimationTracks()
		for _,v in pairs(ActiveTracks) do
			v:Stop()
		end
	end
end)

I’m trying to create 3-moving states: walk, trot, run. Trot and walk are working fine. Anyways I feel like there is overall better way to do this, so all the suggestions are welcome. Thank you.

1 Like

I sort of solved the problem by publishing my game, but I’d still like to hear some alternative ways because my code feels very clumsy. For example the animation doesn’t change if I change the state while humanoid is running.

1 Like

I might be misunderstanding the question, but are you sure you haven’t accidentally put a breakpoint in your code causing you to enter debug mode (Check for a red dot on the left hand side next to the line numbers, click the dot to remove it)?

2 Likes

Ok, so that’s the purpose of the red dot. And yes, I have propably placed it there accidentally oops😅.
Thank you.

1 Like