Hi everyone! While testing my game, I realized that my intermission system wasn’t working.
I thought it was just me accidently changing something, so I looked at my code. However, I couldn’t find any errors. This system fires to all clients during the countdown, so I tried to output something in my receiving local script. Nothing printed out.
In fact all my other remoteevents are also broken. They do fire eventually, but after 1-2 minutes, which is a huge delay.
game.ReplicatedStorage.Events.IntermissionCountdown.OnClientEvent:Connect(function(timeCount)
local plrGUI = plr.PlayerGui
local MainGUI = plrGUI:WaitForChild("MainGui",30)
if MainGUI then
local timer = MainGUI.InterM.Timer
local title = MainGUI.InterM.Title
local textbox = MainGUI.InterM.Text
textbox.Text = ""
title.Text = "Intermission"
if math.floor(timeCount/10) == 0 then
timer.Text = "0:0"..tostring(timeCount)
else
timer.Text = tostring(math.floor(timeCount/60))..":"..tostring(timeCount-60*math.floor(timeCount/60))
end
end
end)
This is unrelated to the main topic but I’ve had the same problem, where only wait() seemed to fix code. However using RunService.Heartbeat:Wait() or RunService.Stepped:Wait() instead of wait() is much faster.
Ok guys, I think I found the issue, and it’s pretty silly. In the local script that I use to receive the remote event, this line is at the top:
local touchGui = plr.PlayerGui:FindFirstChild("TouchGui") or plr.PlayerGui:WaitForChild("TouchGui",30)
Only mobile players will have TouchGui, so basically my script would be waiting for 30 seconds before executing because of the “WaitForChild(“TouchGui”,30)” statement. If you were playing on PC, this WaitForChild would be an infinite yield without the 30 at the end.
Generally I shouldn’t be setting the timeOut value to such a high number, so that is a mistake on my part.
(By the way, I fixed the issue by checking if the player was on mobile through UserInputService and removing this WaitForChild command, but these topics are unrelated)