Hi guys what im trying to do is calling an event (can be a function too) just only once inside a white loop,
what i want is having a notification every time you get close “X” positios, the problem is i get ten thousand notifications every 1 frame because the while loop keep runing, i try to create a booleand that turn true when i get close to the position but keep like shown a looooooot of notifications.
you can specify a while condition other than ‘true’ or use break
after the notification, it will stop the loop:
notified=false
while not notified do
Wait(1)
if closetoxposition then--your proximity condition
--your notification
notified=true--will stop the loop
end
end
or
while true do
Wait(1)
if closetoxposition then--your proximity condition
--your notification
break
end
end
1 Like
thhanks for the aswer, i try to brake the loop but stop the entire script there, i cant just pause because it doest open the rest of the loop (after the notification open a menu) so if a put a break the menu doest open
You could hide the event inside an if statement. something like:
conditionMet = false --variable outside of the loop
while true do
--code here
if conditionMet then
--event here
conditionMet = false
end
--other code here
end
this will always check conditionMet
variable before running the event. And since we immediately change the variable back to false after we run the event, it should only run once per variable change.
1 Like