RemoteFunction not invoking?
For reasons unknown to me, I compulsively use LocalScripts whenever theoretically possible. I'm using a LocalScript to make a digital clock, and so I'm needing to use a RemoteFunction, which is linked to a Script also inside the GUI, which returns the TimeOfDay as a string.
In Studio, the script(s) work perfectly and the clock works. However, in online mode, after a bit of testing, it appears that the LocalScript doesn't even invoke the RemoteFunction properly (I've tried using print(myFunction:InvokeServer()) and it returns nothing - no output, not even a "nil"). Does anyone know why this might be?
Scripts:
ClientManager (LocalScript)
01 | coroutine.resume(coroutine.create( function () |
02 | script.Parent.Parent.Frame.Frames.Main.TimeLabel.Text = script.Parent.ServerManager.GetServerTime:InvokeServer() |
04 | script.Parent.ServerManager.GetServerTime.ServerTimeChanged.OnClientEvent:connect( function () |
05 | script.Parent.Parent.Frame.Frames.Main.TimeLabel.Text = script.Parent.ServerManager.GetServerTime:InvokeServer() |
ServerManager (Script)
02 | last = tostring (game:GetService( "Lighting" ).TimeOfDay), |
03 | current = tostring (game:GetService( "Lighting" ).TimeOfDay), |
06 | function script.GetServerTime.OnServerInvoke() |
07 | return tostring (game:GetService( "Lighting" ).TimeOfDay) |
10 | game:GetService( "Lighting" ).Changed:connect( function (property) |
11 | if tostring (property):lower() = = "timeofday" then |
12 | TimeStats.current = tostring (game:GetService( "Lighting" ).TimeOfDay) |
14 | if TimeStats.current ~ = TimeStats.last then |
15 | script.GetServerTime.ServerTimeChanged:FireClient(script.Parent.Parent.Parent.Parent) |
Additionally, ServerTimeChanged is a RemoteEvent that is fired whenever the TimeOfDay is changed. I also hate using while loops. Again, I don't know why.
Many thanks.