Everything is “working” its just that the remoteevent sometimes won’t fire at the beginning of the game, which breaks it.
script is located in ServerScriptService
remoteevent fires to the localscript correctly
vote:FireAllClients() is a remoteevent that is firing to the vote local script to activate the voting process
local function RoundTimer()
votingTime.Value=true
task.wait(1)
while wait() do
vote:FireAllClients()--the remote event wont fire in actual game but will fire normally in studio testing localserver 1 player
print("voting system fired")
for i=intermissionlength, 0,-1 do
timerwhite:FireAllClients()
seconds=0
inround.Value=false
wait(1)
respawn=false
roundstatus.Value="Round starting in:"..i
showicon:FireAllClients()
end
--anextbotspawnsender:FireAllClients()
showclockicon:FireAllClients()
for i=roundlength, 0, -1 do
votingTime.Value=false
if seconds>=TimerWillTurnRedAt then
timered:FireAllClients()
else
timerwhite:FireAllClients()
end
inround.Value=true
wait(1)
seconds+=1
--print(seconds)
roundstatus.Value= i
end
for i, nextbotsinworkspace in pairs(workspace.CurrentNextbots:GetChildren()) do
nextbotsinworkspace:Destroy()
end
Destroymap:FireAllClients()
votingTime.Value=true
warn("HIHIHI")
vote:FireAllClients()
end
end
spawn(RoundTimer)
The weird thing is, is that THE REMOTE EVENT WORKS IN STUDIO BUT NOT IN THE ACTUAL GAME!
maybe this has to do with lag or my very messy and uncoordinated scripting
please help, this bug is very annoying and I am losing my patience quickly.
Also, I tried moving the fire all clients out of the wait() loop, but it still does the same thing. Everything is working properly except the remoteevent does not fire.
It’s a race condition. What’s happening right now is that the roblox server launches, which results in your code running. However, the player who joined that newly created server is still loading in, which means the server is running FireAllClients before any clients have actually connected to the game. It’ll work in studio since everything is running on your own PC so you dont have to worry about network latency. A really hacky fix to your problem could be to add an infinite wait until at least one player has connected before you call FireAllClients, but typically there are better ways to handle it.