If I make lets say an OnClientEvent:Connect(function() then if I make a while true do loop inside that connection does Disabling the connection effectivley break the while true do loop
what I mean
local Connection = Remote.OnClientEvent:Connect(function()
while true do
print("Will this loop break")
task.wait()
end
end)
task.wait(4)
Connection:Disable()
if not how can I stop this loop when I disable the connection
Thanks!
No it wouldn’t. Disconnecting from an event only stops the script from listening to the event.
To stop the loop in there as well you would do
local Connection = Remote.OnClientEvent:Connect(function()
while Connection.Connected do
print("Will this loop break")
task.wait()
end
end)
task.wait(4)
Connection:Disconnect()
To reset it to listen again, you would simply set byebye back to true on the client, and then have the server fire the event again.