This is not a request site, but I'll help.
Make sure this is a script, not a local script. If your warning system is a GUI, you can fire a remote event to this script. More information here.
local DataStoreService = game:GetService("DataStoreService")
local warnsystem = DataStoreService:GetDataStore("warnsystem")
game.Players.PlayerAdded:connect(function(plr)
local system = Instance.new("Folder")
system.Name = system
system.Parent = plr
local secondsuntilunwarn = Instance.new("NumberValue")
secondsuntilunwarn.Name = secondsuntilunwarn
secondsuntilunwarn.Value = warnsystem:GetAsync(player.UserID) or 0
secondsuntilunwarn.Changed:Connect(function()
warnsystem:SetAsync(player.UserID, secondsuntilunwarn.Value)
end
)
end
)
game.ReplicatedStorage.RemoteEvent.OnServerEvent:Connect(function(plr)
local target = os.time() + 32400
local function toHMS(s)
return ("i:i:i"):format(s / 3600, s / 60 % 60, s % 60)
end
plr.system.secondsuntilunwarn.Value = os.time()
local HMS_Until_Unwarn = (toHMS(target - plr.system.secondsuntilunwarn.Value))
end
)
What is os.time?
os.time returns how many seconds have passed since the Unix epoch (1 January 1970, 00:00:00), under current UTC time. If provided a table formatted similarly to that returned by os.date, it will return the number of seconds since that time instead.
How can I fire client to server using remote events?
local RemoteEvent = game.ReplicatedStorage.RemoteEvent
RemoteEvent:FireServer(data)
2 comments
You could use os.time() to record the time in seconds.
or tick()