Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

RemoteFunction not invoking?

Asked by 10 years ago

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)

01coroutine.resume(coroutine.create(function() -- TimeLabel
02    script.Parent.Parent.Frame.Frames.Main.TimeLabel.Text = script.Parent.ServerManager.GetServerTime:InvokeServer()
03 
04    script.Parent.ServerManager.GetServerTime.ServerTimeChanged.OnClientEvent:connect(function()
05        script.Parent.Parent.Frame.Frames.Main.TimeLabel.Text = script.Parent.ServerManager.GetServerTime:InvokeServer()
06    end)
07end))
08 
09-- 3Tech
10-- Do not redistribute!

ServerManager (Script)

01local TimeStats = {
02    last = tostring(game:GetService("Lighting").TimeOfDay),
03    current = tostring(game:GetService("Lighting").TimeOfDay),
04}
05 
06function script.GetServerTime.OnServerInvoke()
07    return tostring(game:GetService("Lighting").TimeOfDay)
08end
09 
10game:GetService("Lighting").Changed:connect(function(property)
11    if tostring(property):lower() == "timeofday" then
12        TimeStats.current = tostring(game:GetService("Lighting").TimeOfDay)
13 
14        if TimeStats.current ~= TimeStats.last then
15            script.GetServerTime.ServerTimeChanged:FireClient(script.Parent.Parent.Parent.Parent)
View all 21 lines...

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.

0
Can't you just read TimeOfDay from the LocalScript? chess123mate 5873 — 10y

Answer this question