Hello, I am going to teach you how to make a live event that will occur in every server, for this you need Unix time, and some scripting knowledge.
What is Unix time
Unix time is the amount of seconds counted since new years of 1970.
to know the time you can as the output to print(os.time())
Anyways, I am going to make an event for the new year of 2022, the idea is for a rocket to fly.
For this example I am going to insert a mesh from the toolbox, I inserted an Attachment named smoke with a particle emitter
Then I will insert a script inside ServerScriptService, and wrote this code(Please don’t just copy and paste take time to read and understand each line.)
local TimeToStart = 1640995200 -- I used a unix time calculator to get the time for 12 AM 2022, new years.
local TimeToStop = 1640998800 -- time until 1 AM is when the event ends.
function LiveEvent()
local bodyforce = Instance.new("BodyForce") -- creates bodyforce.
bodyforce.Force = Vector3.new(0,1000000,0) -- I added a number on the Y axis so it flies away.
bodyforce.Parent = game.Workspace.Rocket -- Parents bodyforce to rocket
game.Workspace.Rocket.Anchored = false
game.Workspace.Rocket.smoke.PE.Enabled = true -- makes smoke appear
end
while wait(1) do
local TimeNow = os.time() -- current unix time
if TimeNow >= TimeToStop then -- if the unix time is greater than or equal to the time to stop the code stops.
break
end
if TimeNow >= TimeToStart then -- if the unix time is greater than or equal to the time to start the code calls the live event function.
print("Live event is starting!")
LiveEvent()
break
else
print("Time till live event ".. (TimeToStart-TimeNow).." seconds") -- amount of seconds till event.
end
end
this script works I tested it out on a different time and the rocket launched, I discovered that the size of the rocket matters so replace the numbers on the body force or it might just fall or fly away too fast.
this is the link to the game if anyone wants to visit, nothing will happen until new years
Thanks for reading
– Credit to AlvinBlox, he is one of the best roblox scripting youtuber if you want to start out, I recommend you watch him!
AlvinBlox if you are reading this, Hi! your vids are amazing