Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

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

Asked by 6 years ago
Edited 6 years ago

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!

0
Is that code the full script? If not, could you please paste it so we can see if there are other errors? ax_gold 360 — 6y
0
you could try anchoring a part welded to the player's character. Le_Teapots 913 — 6y

3 answers

Log in to vote
2
Answered by
Amiaa16 3227 Moderation Voter Community Moderator
6 years ago

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)
Ad
Log in to vote
0
Answered by
CPF2 406 Moderation Voter
6 years ago

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)
Log in to vote
0
Answered by 4 years ago

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 :)

Answer this question