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

How to freeze player when touching a part?

Asked by
Paradoa 17
4 years ago
Edited 4 years ago

Perhaps anchoring could help, but I've tried anchoring the humanoid root part and other body parts and it doesn't work. Did I miss something in this script?

function onPartTouch()
    game.StarterPlayer.StarterCharacter."Body Part".Anchored = true
end

script.Parent.Touched:Connect(onPartTouch)

4 answers

Log in to vote
0
Answered by 4 years ago
Edited 4 years ago

Maybe try:

function onTouch(hit)
    local player = hit.Parent:WaitForChild("HumanoidRootPart")
    if player then
        player.Anchored = true
    end
end
script.Parent.Touched:Connect(onTouch)
Ad
Log in to vote
0
Answered by 4 years ago

Instead of anchoring the HumanoidRootPart, anchor the torso itself. The character's arms and legs are connected to it, which will stop everything if you anchor the torso.

Hope this helps!

Log in to vote
0
Answered by
DesertusX 435 Moderation Voter
4 years ago

How about setting the Humanoid.WalkSpeed to 0.

function onPartTouch(char)
    if char:FindFirstChild("Humanoid") then
        char:FindFirstChild("Humanoid").WalkSpped = 0
end

script.Parent.Touched:Connect(onPartTouch)

Hope this helps!

Don't forget to accept this answer if it does!!

Log in to vote
0
Answered by
Axenori 124
4 years ago

This version works for both R6 and R15, It will also work for custom characters

function Touched(hit)
if hit.Parent ~= nil then
if  hit.Parent:FindFirstChild("Humanoid") then
local GC = hit.Parent:GetChildren()
for i, v in pairs(GC) do
    if v:IsA("BasePart") then
v.Anchored = true
end
end
end
end
end
script.Parent.Touched:Connect(Touched)

Answer this question