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

How do I freeze the character in place?

Asked by
Swolcu 2
5 years ago

This script to freeze the character isn't working. Help?

local player = game.Players.LocalPlayer
local torso = player:WaitForChild('UpperTorso')

torso.Anchored = true

2 answers

Log in to vote
1
Answered by
Thetacah 712 Moderation Voter
5 years ago
Edited 5 years ago

UpperTorso is within the Character, not the Player.

I've created a variable character. The or statement is there in case the script loads before the character does, which would result in an error.

local player = game.Players.LocalPlayer
local character = player.Character or player.CharacterAdded:Wait()
local torso = character:WaitForChild("UpperTorso")
wait(2)
torso.Anchored = true
0
I just want to comment that you cant use LocalPlayer to get the Character Torso. the Character is in your Workspace. While your Player is in Players. When you call LocalPlayer. Thats asking for your Player in Players. Not your Character. The Torso is a child of your Character VectorFoo 0 — 3y
Ad
Log in to vote
0
Answered by 5 years ago
Edited 5 years ago
local player = game.Players.LocalPlayer
local character = player.Character or player.CharacterAdded:Wait()
local head = character:FindFirstChild("Head") or character:WaitForChild("Head")
head.Anchored = true

or

local player = game.Players.LocalPlayer
local character = player.Character or player.CharacterAdded:Wait()
local humanoid = character:FindFirstChild("Humanoid") or character:WaitForChild("Humanoid")
local canjump = false

humanoid.WalkSpeed = 0

humanoid:GetPropertyChangedSignal("Jump"):Connect(function()
    if canjump == false then
    humanoid.Jump = false
    end
end)

or

local player = game.Players.LocalPlayer
local character = player.Character or player.CharacterAdded:Wait()
local humanoid = character:FindFirstChild("Humanoid") or character:WaitForChild("Humanoid")

if humanoid.RigType == Enum.HumanoidRigType.R15 then
local uppertorso = character:FindFirstChild("UpperTorso") or character:WaitForChild("UpperTorso")
uppertorso.Anchored = true
elseif humanoid.RigType == Enum.HumanoidRigType.R6 then
local torso = character:FindFirstChild("Torso") or character:WaitForChild("Torso")
torso.Anchored = true
end

Answer this question