I’m not sure what I was doing at all.
But I need help on something/Like the topic I posted. How could I do like… when the years (IN REAL TIME) become 2021 or any year. something happens? like a part becomes invisible Anything!
like live events.
Scripts, videos, anything helps please and thank you !
You can use tick() to get the current time and calculate the future time you want based on time from the UNIX epoch. I bet there are websites to do so.
Then you just need a delayed look to check if the current tick() is greater than your calculated one. You can use game:GetService("RunService").Heartbeat:Wait() or Wait(x) to delay the loop. You can also directly connect into heartbeat.
Edit:
Here is a website to get the number that will be returned by tick() at a specific time/date: https://www.unixtimestamp.com/index.php
I have a doubt about ur new year event. On every country the new year will be in a different time. Your live event will be based on your own time of ur country?
I still dont get it xD
Me and my friend join the server, me from america she’s from asia. She’s having this time stamp 1609459200 which is 01/01/2021 12am. And for me its 31/12/2020 12pm.
The new year live event, will trigger for her and not for me?
I was just saying that UNIX time is based on the same timezone always (UTC). It doesn’t matter if the server is in Asia or if it is in California, os.time() (UNIX) will return the same.
Yeah, I was just thinking about logic. I would expect everyone in the server to experience the live event. Not depending on timezones. Then should be based on a specific “server time”?
So everyone inside the server, experience the event, but if theres ppl around the world in the server, still weird having a new year event when its a different date and time for everyone.
Or just trigger it for the ppl who is having real new year?
@Oozymage I used a quick time converter and it seems in UTC new years will fall at this time in seconds since the epoch.
1609416000
Do what @PseudoPerson said and use some form of loop to repeatedly check if tick() or os.time() is equal to or greater than this time and then do what you originally had in your other post. (I would recommend using while wait(1) do to check every second for performance reasons)
game.Players.PlayerAdded:Connect(function(player)
while wait(1) do
local currentTime = os.time()
if currentTime >= 1609416000 then
---Anything happens here---
end
end
end)
Indeed! In fact, you don’t even need to create a PlayerAdded connection here. You can just have the while loop by itself.
while wait(1) do
if os.time() >= 1609416000 then -- We can also simplify currentTime down to this instead of creating a variable for it. It does the exact same thing but saves some lines. Up to personal preference though so you can decide.
---Anything happens here---
end
end
Just in case, I would run a test where you replace 1609416000 with the time about like 2 or so minutes away and then join to see if it works.
I suggest you finish the event before the new year and you have to launch the event manually and update your game when the players are in your game as little as possible