guys, how can I break a while loop using Touch:Connect, I had try this but it got red out
while true do
map:WaitForChild("wayout").Wayout.Touched:Connect(function(hit)
if hit.Parent:FindFirstChildWhichIsA("Humanoid") and hit.Parent:FindFirstChild("Target") then
break-- I got red out on this
end
end)
end
I’m not sure why you need a while loop if it’s only just the Touched function but it will be something like this:
local breakLoop = true -- if this becomes false loop stops
map:WaitForChild("wayout").Wayout.Touched:Connect(function(hit)
if hit.Parent:FindFirstChildWhichIsA("Humanoid") and hit.Parent:FindFirstChild("Target") then
breakLoop = false -- break the running loop
end
end)
while breakLoop do -- run until breakLoop becomes false
task.wait() -- without this while loop will run too fast
end