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

What's wrong with my scripts ? 24 hours system won't work.

Local script:

game.ReplicatedStorage.Work.OnClientEvent:Connect(function(hours,minutes,seconds)
	script.Parent.Text = "hours: "..hours.." minutes: "..minutes.." seconds: "..seconds
end)

Server script:

local TIME = tick() --edit: or os.time()?, read thread for more info

--getting seconds left in a day:
local currentExactDay = TIME/86400 --86400 seconds in a day
local roundedDay = math.floor(currentExactDay)
local dayFraction = currentExactDay - roundedDay --value between 0-1
local secondsInDay = math.floor(dayFraction * 86400) --seconds left in a day
local secondsLeft = 86400 - secondsInDay 

--converting it for your timer:
local hours = math.floor(secondsLeft/3600)
local minutes = math.floor((secondsLeft%3600)/60)
local seconds = secondsLeft%60
game.ReplicatedStorage.Work:FireAllClients(hours,minutes,sec)

So basically I'm trying to make a 24 hour system, neither that work or change my text.. What i do?..

2 answers

I copied all of your code, and your problem seems to be in that your server-sided code isn't inside of a loop.

The only problem that i could find was that you don't actually input the seconds value.

local TIME = tick() --edit: or os.time()?, read thread for more info

--getting seconds left in a day:
local currentExactDay = TIME/86400 --86400 seconds in a day
local roundedDay = math.floor(currentExactDay)
local dayFraction = currentExactDay - roundedDay --value between 0-1
local secondsInDay = math.floor(dayFraction * 86400) --seconds left in a day
local secondsLeft = 86400 - secondsInDay 

--converting it for your timer:
local hours = math.floor(secondsLeft/3600)
local minutes = math.floor((secondsLeft%3600)/60)
local seconds = secondsLeft%60
game.ReplicatedStorage.Work:FireAllClients(hours,minutes,seconds)

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