How would I make a decal change every week

So I want to make a timer which still goes on when players leave the game, and I want it to wait 1 week and then update a decal on a part. I would assume I would have to use something like os.time()?

PS: This is for a weekly fan art type of thing

function changedecal() -- Whatever function you want to name it
-- Change decal
end

wait(604800 - os.time()%604800)
changedecal()
while wait(604800) do
changedecal()
end

I think this should work fine. 604800 is equal to one week in secs. And yeh, your on the right track. You going to need to use os.time

1 Like

Thanks so much, would this work even if the player isn’t in the server/

Is this play time or real time?

It’s real time, I want it to change every week even when the player isn’t in the server.

What’s the modulus for? Why do you have to return teh remainder? I’m confused.

No, I mean: This script right now: Would not run real time.

this wouldnt run when the server ends so the server would still have to run for a week for this manner to change the decal

@FerbZides OP never specified he wanted it to run it synchronised on the server.
@Ulxqra os.time returns the clients time, so it returns the real life time from the client’s machine
@xxIamInevitable I didn’t return the remainder? I’m subtracting the clients time until a week has passed and calling that function

If you want it to run it on the server and not have it reset, your best bet is grab an arbitrary date that’s valid to calculate the time from.

It’s a bit confusing but I suggest you do some research, here are few links:

The percentage is called ‘modulus’, which is basically division, but it instead returns the remainder.

wait(604800 - ostime()%604800)

I think this will work:

while true do
       if os.time("%A") == "43" then
           decalweek43.Parent = display
       elseif os.time("%A") == "44" then
           decalweek44.Parent = display
       end
       wait(0.1)
end
1 Like