Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

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

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

--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)

This discussion is preserved as it was. New answers, comments, and votes are closed.