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

Help with testing if a player is always touching a block?

Asked by 11 years ago

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 \/

01function onTouch(part)
02 
03script.Parent.Parent.Screen.SurfaceGui.Bar.Progress.True.Value = true
04 
05            end
06 
07while wait(1) do
08script.Parent.Touched:connect(onTouch)
09 
10end

How would I do that?

1 answer

Log in to vote
0
Answered by 11 years ago

You need to make a while loop checking if the parent "Humanoid" exists, something like this:

1function 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
7end
8 
9script.Parent.Touched:connect(onTouch)
0
Still doesn't work? I Am not sure why unix_system 55 — 11y
0
try to remove "while humanoid do wait(1) end" alessandro112 161 — 11y
0
I mean, it works by itself, but it still counts down even when the player isn't touching it. unix_system 55 — 11y
0
add an if statement to check if the humanoid still exists alessandro112 161 — 11y
View all comments (2 more)
0
Ok, all I have done is made it a click detector unix_system 55 — 11y
0
lolwat? Touched and ClickDetector doesn't make any sense anyway if it works so hold the ClickDetector alessandro112 161 — 11y
Ad

Answer this question