Hey guys,
So my latest game uses Remote Functions to launch a GUI on the player's screen. This function is then located within a while true loop.
The rest of the script functions as it should, but when it loops around the remote event does not work since it is still broadcasting from the last time. Here is an idea of the code used below.
--Server Script local raceLight = Instance.new("RemoteFunction") raceLight.Name = "raceLights" raceLight.Parent = game.Workspace while true do --Stuff about loading the map here wait(1) function raceLight.OnServerInvoke() print("sending out function") return "success" end --Stuff about the race and removing the map here end
^^^This is not the full code, just a snippet where I have the problem!^^^
--Local Script located in StarterPlayerScripts local message = game.Workspace.raceLight:InvokeServer() game.Players.LocalPlayer.PlayerGui.StartingLights.Lights.Visible = true wait(2) game.Players.LocalPlayer.PlayerGui.StartingLights.Lights.Seq.Disabled = false print(message)
Is there a way to get the function to stop broadcasting, or should I try another Remote Event style?
Place the OnServerInvoke function outside the loop (after creating RemoteFunction object and before line with while true do )