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

How to freeze player when touching a part?

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

✓ Accepted answer

Maybe try:

function onTouch(hit)
	local player = hit.Parent:WaitForChild("HumanoidRootPart")
	if player then
		player.Anchored = true
	end
end
script.Parent.Touched:Connect(onTouch)

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!

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!!

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)

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