Remote event fires from an If statement, even without FireServer()

What do you want to achieve?

I want to find a way to start a Round system from a remote event that’s triggered by a UI button

What is the issue?

The remote event fires when I join the game, even without the Ui button being pressed, which fires the remote event on the server.

Here’s the code from the round manager

image

code from the Button

I found a similar topic, but that issue was caused by the remote event being fired without a condition inside another script. Are there any fixes to this issue that I should consider using?

That’s not how you use RemoteEvents.

If you want a connection to prevent code from running, then use a flag variable in the top scope.

local start = false

remoteEvent.OnServerEvent:Connect(function()
	start = true
end

while true do
	if start then
		start = false -- remember to reset it
		...
	end
end

This method worked perfectly, thanks!

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.