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


function onTouch(part) script.Parent.Parent.Screen.SurfaceGui.Bar.Progress.True.Value = true end while wait(1) do script.Parent.Touched:connect(onTouch) end

How would I do that?

1 answer

Log in to vote
0
Answered by 10 years ago

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

function onTouch(part)
    local humanoid = part.Parent:FindFirstChild("Humanoid")
    while humanoid do -- While the humanoid exists do....
        script.Parent.Parent.Screen.SurfaceGui.Bar.Progress.True.Value = true
        wait(1) -- We wait 1 second before progressing again the bar
    end
end

script.Parent.Touched:connect(onTouch)

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

Answer this question