Hello! I want to create a script where something repeats until the player gets touched.
repeat
// do stuff
until player.Humanoid.Touched
But, the thing above me does not work, does anyone know something that will work?
Hello! I want to create a script where something repeats until the player gets touched.
repeat
// do stuff
until player.Humanoid.Touched
But, the thing above me does not work, does anyone know something that will work?
You can use the following code:
local humanoidTouched: boolean = false
--typechecking so the humanoidTouched is boolean type. if this line of code fails, remove ": boolean" part.
task.spawn(function()
character.Humanoid.Touched:Wait() --resumes execution when signal is fired
humanoidTouched = true
end) -- create a thread that waits until humanoid touches something.
repeat
--do code
task.wait() --IMPORTANT: Removing it may cause studio to crash unless there are other yielding methods!
until humanoidTouched --will repeat until humanoid touches something