I'm currently making a plane, so I don't want to use Admin all the time for freeze myself in the plane. How do I make a script that freezes the person? This must prevent the whole plane from moving Thx for the help!
First of all, this is a request. You should try by yourself first. But, I wanna help out anyway. Now, you're not being very descriptive. So I'll assume, that you want to freeze the player when, let's say he touches a part.
01 | local part = script.Parent |
02 | local db = false |
03 |
04 | function freeze(hit) |
05 | local human = hit.Parent:FindFirstChild( "Humanoid" ) |
06 | if human then -- checks if a human touched it |
07 | if not db then |
08 |
09 | db = true -- turns debounce on to prevent repetition of the script |
10 |
11 | human.Parent.Torso.Anchored = true -- This is one way to freeze the player. Another way is "human.Parent.WalkSpeed = 0" |
12 |
13 | end end end -- They look nice beside each other, don't you think? |
14 |
15 | part.Touched:connect(freeze) --uses touch event. |
This script is put in the part you want to be touched. Hope this helped! If it did, please don't forget to accept my answer. If you have any questions, feel free to comment!
Fix to Peeshavee's script, his only freezes the torso.
01 | local part = script.Parent |
02 | local db = false |
03 |
04 | function freeze(hit) |
05 | local human = hit.Parent:FindFirstChild( "Humanoid" ) |
06 | if human then -- checks if a human touched it |
07 | if not db then |
08 |
09 | db = true -- turns debounce on to prevent repetition of the script |
10 |
11 | human.Parent.Torso.Anchored = true |
12 | human.Parent.Head.Anchored = true |
13 | human.Parent.Left Leg.Anchored = true |
14 | human.Parent.Left Arm.Anchored = true |
15 | human.Parent.Right Arm.Anchored = true |
16 | human.Parent.Right Leg.Anchored = true |
17 |
18 | end end end -- They look nice beside each other, don't you think? |
19 |
20 | part.Touched:connect(freeze) --uses touch event. |
To unfreeze, simply just set Anchored to false.