breakfunction = false
script.Parent.Clickdetector.MouseButtonClick:Connect(function()
--function
wait(1)
if breakfunction == true then
return nil -- this breaks the function
end
--function
end)
remoteEvent.OnServerEvent:Connect(function()
breakfunction = true
end)
1-Using Disconnect.
2-Using Variables[such as BoolValues] -with them, you’ll be able to set and check conditions.
[if a certain condition has occurred, you could return nil, and stop the function].
For e.g :
You could pass a variable[let’s say , a boolean], to the server, and if it’s true, stop the function by returning nil]