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

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

Asked by 4 years ago

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

Log in to vote
0
Answered by 4 years ago
Edited 4 years ago

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

Ad
Log in to vote
0
Answered by 4 years ago

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)

Answer this question