Lets say I have a script that listens for a remote event to get fired.
local remote = game:GetService("ReplicatedStorage").Remote
remote.OnServerEvent:Connect(function(plr, ...)
-- Do something
end)
How can I stop listening / waiting for the remote event to be fired? I assume I would do something like this?
local remote = game:GetService("ReplicatedStorage").Remote
local connection = remote.OnServerEvent:Connect(function(plr, ...)
-- Do something
end)
connection:Disconnect()
Meta_data’s post should be the best option here, i just want to give my own solution for this, which is not very recommended, i guess:
What i would do is use a boolean thing, here is an example:
local remote = game:GetService("ReplicatedStorage").Remote
local Boolean = false
remote.OnServerEvent:Connect(function(plr, ...)
if not Boolean then
print("Event Recieved, you can write your code here")
end
end)
wait(10)
Boolean = true
I think you know what everything inside the code means. Thanks for reading.