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

Server-side Time that player can resync to. Help?

Asked by 6 years ago

Greetings.

I've come into another obstacle that has stumped me for the last few weeks, and I've decided to try at it again.

I am attempting to create a system where the player can change the time to whichever they choose-- but be able to resync back with the server's time (it's running on a day/night script) if they so choose. I've tried a few things, and so far, I have created a value that basically reads from the ClockTime in Lighting

while true do
    game.ReplicatedStorage.ServerTime.Value = game.Lighting.ClockTime
    wait()
end

My theory was that this value would be from the server, but in my tests, when the player sets a time of their own, the value of ServerTime is set to whatever the player has set, not what the server's been running at.

So my question is how do I get this to properly work? Am I doing the complete opposite/wrong thing for this kind of task?

Thanks.

1 answer

Log in to vote
0
Answered by 6 years ago
--Wrap the code in a changed event. Gotta use GetService.

local rep = game:GetService("ReplicatedStorage")
local lighting = game:GetService("Lighting")

lighting.Changed:Connect(function(property)
    rep.ServerTime.Value = lighting.ClockTime
end)
Ad

Answer this question