How do I make a screen GUI that goes 12pm 1am 2am 3am 4am 5am 6am and then teleports you to another game? I want to know because I am making a Five Nights At Freddy's game.
First we must get the variables
local TimeGUI = script.parent -- Or whereever it is local waitTime = 5 -- Or how long between each hour local TeleportService = game:GetService("TeleportService")
Then we add a function
game.Players.PlayerAdded:Connect(function(plr) end)
Next, we must make the waits
game.Players.PlayerAdded:Connect(function(plr) wait(waitTime) wait(waitTime) wait(waitTime) wait(waitTime) wait(waitTime) wait(waitTime) end)
In between those we change the text
game.Players.PlayerAdded:Connect(function(plr) TimeGui.Text = "12pm" wait(waitTime) TimeGui.Text = "1am" wait(waitTime) TimeGui.Text = "2am" wait(waitTime) TimeGui.Text = "3am" wait(waitTime) TimeGui.Text = "4am" wait(waitTime) TimeGui.Text = "5am" wait(waitTime) TimeGui.Text = "6am" end)
Now we must teleport (taken straight from the roblox wiki)
game.Players.PlayerAdded:Connect(function(plr) local yourplace = 123456789 -- ID of your game local destination = 408502380 -- ID of the game you want to be sent to TimeGui.Text = "12pm" wait(waitTime) TimeGui.Text = "1am" wait(waitTime) TimeGui.Text = "2am" wait(waitTime) TimeGui.Text = "3am" wait(waitTime) TimeGui.Text = "4am" wait(waitTime) TimeGui.Text = "5am" wait(waitTime) TimeGui.Text = "6am" TeleportService:Teleport(destination, player) end)
With that all combined we have this!
local TimeGUI = script.parent -- Or whereever it is local waitTime = 5 -- Or how long between each hour local TeleportService = game:GetService("TeleportService") game.Players.PlayerAdded:Connect(function(plr) local destination = 123456789 -- ID of the game you want to be sent to local yourplace = 987654321 -- ID of your game TimeGui.Text = "12pm" wait(waitTime) TimeGui.Text = "1am" wait(waitTime) TimeGui.Text = "2am" wait(waitTime) TimeGui.Text = "3am" wait(waitTime) TimeGui.Text = "4am" wait(waitTime) TimeGui.Text = "5am" wait(waitTime) TimeGui.Text = "6am" TeleportService:Teleport(destination, player) end)