Hi everyone,
I wanted to find out how to test if a player is always touching a block? I am making a terminal script
SCRIPT \/
01 | function onTouch(part) |
02 |
03 | script.Parent.Parent.Screen.SurfaceGui.Bar.Progress.True.Value = true |
04 |
05 | end |
06 |
07 | while wait( 1 ) do |
08 | script.Parent.Touched:connect(onTouch) |
09 |
10 | end |
How would I do that?
You need to make a while loop checking if the parent "Humanoid" exists, something like this:
1 | function onTouch(part) |
2 | local humanoid = part.Parent:FindFirstChild( "Humanoid" ) |
3 | while humanoid do -- While the humanoid exists do.... |
4 | script.Parent.Parent.Screen.SurfaceGui.Bar.Progress.True.Value = true |
5 | wait( 1 ) -- We wait 1 second before progressing again the bar |
6 | end |
7 | end |
8 |
9 | script.Parent.Touched:connect(onTouch) |