How do i make a Player Anchored When the Part touched

this is probably very easy for you guys But, How do i make a Player Anchored When the Part touched
i also don’t want other players get anchored As well if the other players didn’t touch the part

1 Like

Assuming the script is inside the part

script.Parent.Touched:Connect(function(hit)
    if game.Players:GetPlayerFromCharacter(hit.Parent) then
        hit.Parent:WaitForChild("HumanoidRootPart").Anchored = true
    end
end)

Just a simple explanation.
Line 1: I check when something touches the part. And yes there is a parameter which is hit (The part that touches).
Line 2: I check if the part’s parent is a player in the Players service. If it is then…
Line 3: I anchor the player’s HumanoidRootPart because it is the main part for the player’s character.

4 Likes

part.touched:Connecr(function(hit)

if hit.Parent:FindfFirstChild(“Humanoid”) then
hit.Parent.Torso.Anchored == true ------- this for r6
hit.Parent.LowerTorso.Anchored == true ------- this for r15
end
end
end

1 Like

yes it is thank you and sorry for my bad English I’m from the Philippines

1 Like

No problem! You’ll gradually learn a lot more than you’re now!

Plus I gave an explanation so you can understand what happens!

1 Like

thank you i really appreciated

1 Like