Player Stays Frozen After Respawn – How to Prevent This?

Hey devs!

I’m trying to create a main menu in my game where the player is frozen (WalkSpeed = 0) until they press a “Play” button. This works fine at first, but when players die and respawn during the match, they sometimes stay frozen and can’t move.

Here’s what I’ve tried so far:

  • CharacterAdded event to set WalkSpeed back to 16 after the player respawns.
  • Checking if the player is in the menu (isInMenu flag) to control movement.
  • Humanoid.Died event to reset movement.

However, the issue persists, and the player often stays frozen even when they respawn during the match. I’d love to know:

  1. How do I ensure WalkSpeed is always reset on respawn during the match?
  2. Is there a more reliable way to freeze/unfreeze the player only when they’re in the menu?

also here is the script that i used:

local player = game.Players.LocalPlayer
local camera = workspace.CurrentCamera
local menuCameraPosition = workspace:WaitForChild("MenuScene"):WaitForChild("MenuCameraPosition")
local mainMenuGui = player:WaitForChild("PlayerGui"):WaitForChild("MainMenuGui")
local isInMenu = true 


local function setPlayerMovement(walkSpeed, jumpPower)
	if player.Character then
		local humanoid = player.Character:FindFirstChild("Humanoid")
		if humanoid then
			humanoid.WalkSpeed = walkSpeed
			humanoid.JumpPower = jumpPower
		end
	end
end


local function enterMenu()
	isInMenu = true
	setPlayerMovement(0, 0)
	camera.CameraType = Enum.CameraType.Scriptable
	camera.CFrame = menuCameraPosition.CFrame
	mainMenuGui.Enabled = true
end


local function exitMenu()
	isInMenu = false
	setPlayerMovement(16, 50) 
	camera.CameraType = Enum.CameraType.Custom
	mainMenuGui.Enabled = false
end


player.CharacterAdded:Connect(function(character)
	local humanoid = character:WaitForChild("Humanoid")


	humanoid.Died:Connect(function()
		if not isInMenu then
			setPlayerMovement(16, 50)
		end
	end)

	if isInMenu then
		setPlayerMovement(0, 0) 
	else
		setPlayerMovement(16, 50)
	end
end)


local playButton = mainMenuGui:FindFirstChild("PlayButton")
if playButton then
	playButton.MouseButton1Click:Connect(exitMenu)
end


enterMenu()

Any help would be appreciated! Thanks! :smile:

came up with this, dont know whether this works or not

mixed up my words

local player = game.Players.LocalPlayer
local camera = workspace.CurrentCamera
local menuCameraPosition = workspace:WaitForChild("MenuScene"):WaitForChild("MenuCameraPosition")
local mainMenuGui = player:WaitForChild("PlayerGui"):WaitForChild("MainMenuGui")
local isInMenu = true

local function setPlayerMovement(walkSpeed, jumpPower)
	if player.Character then
		local humanoid = player.Character:FindFirstChild("Humanoid")
		if humanoid then
			humanoid.WalkSpeed = walkSpeed
			humanoid.JumpPower = jumpPower
		end
	end
end

local function enterMenu()
	isInMenu = true
	setPlayerMovement(0, 0)
	camera.CameraType = Enum.CameraType.Scriptable
	camera.CFrame = menuCameraPosition.CFrame
	mainMenuGui.Enabled = true
end

local function exitMenu()
	isInMenu = false
	setPlayerMovement(16, 50) 
	camera.CameraType = Enum.CameraType.Custom
	mainMenuGui.Enabled = false
end

player.CharacterAdded:Connect(function(character)
	local humanoid = character:WaitForChild("Humanoid")


	if isInMenu then
		setPlayerMovement(0, 0) 
	else
		setPlayerMovement(16, 50)
	end


	humanoid.Died:Connect(function()
		task.wait(1)
		if not isInMenu then
			setPlayerMovement(16, 50)
		end
	end)
end)

local playButton = mainMenuGui:FindFirstChild("PlayButton")
if playButton then
	playButton.MouseButton1Click:Connect(exitMenu)
end

enterMenu()

the CharacterAdded event runs, but isInMenu is still true, so setPlayerMovement(0, 0) is called

2 Likes

it still doesnt work, ive tried so many new scripts for the past week and still nothing :face_with_head_bandage:, but thanks for your help!

If this script is in StarterCharacterScripts then the enterMenu function will always run when the player respawns making them frozen

its in starterPlayerScripts, i dont think im supposed to put it somewhere else