when OtherPart touches the MainPart the while loop stops, and if the OtherPart stops touching the while loop should start up again. but it does not please help!
local part = script.Parent
debounce = true
function onTouch(part)
if debounce then
if part.Parent:WaitForChild("Otherpart") then
print(part,"Touched")
debounce = false --------------- if touched then stops loop
end
end
end
function onTouchEnded(part)
if part.Parent:FindFirstChild("Otherpart") then
print(part,"Touched Ended")
debounce = true ------------------ if touch Ended then Restarts loop
end
end
part.Touched:Connect(onTouch)
part.TouchEnded:Connect(onTouchEnded)
while debounce do ----------------------------------- loop to start or stop
wait()
part.BrickColor = BrickColor.Random()
end

1 comment
Your a GOD :) Bows Down