Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

My player freeze script does not work. What did I do wrong?

I have this script that freezes the player (Anchors the player) but after the player is frozen, they have this freecam thing. So the HumanoidRootPart moves and is not frozen. And no, I DON'T want to set the WalkSpeed and JumpPower to 0

Code:

for i,v in pairs(character) do
	if v:IsA("BasePart") then
		v.Anchored = true
	end
end

Thanks!

2 comments

0

Is that code the full script? If not, could you please paste it so we can see if there are other errors?

0

you could try anchoring a part welded to the player's character.

3 answers

✓ Accepted answer

If you don't want to change WalkSpeed, you can set PlatformStand to true. It will prevent any movement at all.

function Freeze(player, bool)
	local char = player.Character
	local hum = char:FindFirstChildOfClass("Humanoid")
	for i,v in pairs(char:GetChildren()) do
		if v:IsA("BasePart") then
			v.Anchored = bool
		end
	end
	hum.PlatformStand = bool
end

Freeze(game:GetService("Players").LocalPlayer, true)
wait(2)
Freeze(game:GetService("Players").LocalPlayer, false)

I had this problem earlier, the way I solved it was by using a client event to freeze the player locally. (use this with the script you are already using.)


-- FREEZE
game.ReplicatedStorage.Remotes.TSW.On.OnClientEvent:connect(function()
	Player.PlayerScripts.ControlScript.Disabled = true
	if Player.Character.RigType == 'R6' then
		Player.Character.Torso.Anchored = true
	elseif Player.Character.RigType == 'R15' then
		Player.Character.LowerTorso.Anchored = true
		Player.Character.UpperTorso.Anchored = true
	end
end)

-- UNFREEZE
game.ReplicatedStorage.Remotes.TSW.Off.OnClientEvent:connect(function()
	Player.PlayerScripts.ControlScript.Disabled = false
	if Player.Character.RigType == 'R6' then
		Player.Character.Torso.Anchored = false
	elseif Player.Character.RigType == 'R15' then
		Player.Character.LowerTorso.Anchored = false
		Player.Character.UpperTorso.Anchored = false
	end
end)

Simpler solution:

local player = — your player here
local character = player.character
local humanoid = character.Humanoid

humanoid.WalkSpeed = 0 — default is 13
humanoid.JumpPower = 0 — default depends

You can set them back when needed :)

This discussion is preserved as it was. New answers, comments, and votes are closed.