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

How to track time warned in my warn system?

Asked by 4 years ago

Hi,

In my game there's a warn system, and after 9 hours the warn goes away. I've already got it that a folder called 'Warns' appears in a player every time they join, and there are subfolders with the following values: The admin that warned them, the warn reason and the warn ID.

I need help with the wearing off bit, so that 9 hours later the warn gets deleted.

I've been looking for answers but nothing helped much.

0
You could use os.time() to record the time in seconds. FunctionalMetatable 490 — 4y
0
or tick() Leamir 3138 — 4y

1 answer

Log in to vote
0
Answered by
raid6n 2196 Moderation Voter Community Moderator
4 years ago
Edited 4 years ago

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.

01local DataStoreService = game:GetService("DataStoreService")
02local warnsystem = DataStoreService:GetDataStore("warnsystem")
03game.Players.PlayerAdded:connect(function(plr)
04        local system = Instance.new("Folder") -- making folder
05        system.Name = system -- naming it system
06        system.Parent = plr -- putting it inside of the player
07 
08        local secondsuntilunwarn = Instance.new("NumberValue") -- making a numbervalue
09        secondsuntilunwarn.Name = secondsuntilunwarn -- naming it secondsuntilunwarn
10        secondsuntilunwarn.Value = warnsystem:GetAsync(player.UserID) or 0 -- putting the value to the saved data or 0 if they have no data
11 
12        secondsuntilunwarn.Changed:Connect(function() -- if it changes
13                warnsystem:SetAsync(player.UserID, secondsuntilunwarn.Value) -- save it
14            end
15        )
View all 33 lines...

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?

1local RemoteEvent = game.ReplicatedStorage.RemoteEvent
2 
3RemoteEvent:FireServer(data) -- if you're doing this in the warning system makes the data /parameter player
Ad

Answer this question