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

How would I go about making a teleport GUI utilizing TimeOfDay or ClockTime?

Asked by 5 years ago

For a more in-depth explanation, think of it as a scheduled GUI that appears on the player's screen which offers ("Accept" / "Decline") the player to teleport to a specific coordinate once the TimeOfDay reaches a certain time. I.E: TimeOfDay reaches 14:00:00 so a GUI is then prompted to the player where they can accept or decline whether or not they'll teleport.

I'm just entirely unsure on how/where I should be starting, I'm not expecting it to be done for me but a push in the right direction would be wonderful! Thanks for any contributions.

1 answer

Log in to vote
0
Answered by
niroqeo 123
5 years ago

I'm no advanced scripter or whatnot, so this may not be the best way... But, it works, so I'm going to post it. What you do is insert a remote event into ReplicatedStorage called "Teleport". In StarterGui, insert a ScreenGui, a frame into the ScreenGui, and 2 buttons in the frame. Insert the script below into the button that teleports you (It's a local script).

1script.Parent.MouseButton1Click:Connect(function()
2    game.ReplicatedStorage.Teleport:FireServer() -- fires server event
3    script.Parent.Parent.Visible = false -- makes the frame invisible
4end)

Insert the script below into the button that declines the TP offer (It's a local script).

1script.Parent.MouseButton1Click:Connect(function()
2    script.Parent.Parent.Visible = false -- makes frame invisible
3end)

Insert a server script into StarterCharacterScripts (in StarterPlayer).

1while true do -- loops
2    wait(.1) -- must ALWAYS put wait in loops
3    if game.Lighting.TimeOfDay == "14:00:00" then -- checks if the time is 14:00:00
4                print("did it") -- :)
5                local player = game.Players:GetPlayerFromCharacter(script.Parent) -- gets player
6                player.PlayerGui.ScreenGui.Frame.Visible = true -- i reckon you know what this does
7            end
8    end

Last and certainly least, insert a server script into ServerScriptService.

1game.ReplicatedStorage.Teleport.OnServerEvent:Connect(function(player)
2    local char = player.Character
3    local position = Vector3.new(0,0,0) -- replace 0,0,0 with the vector3 of where you want to tp to
4    if char ~= nil then -- just to be safe, i guess
5    char:MoveTo(Vector3.new(position)) -- way to teleport humanoids
6    end
7end)

Hope this helped!! :D

0
I really do appreciate your help NiroTurtle, you explained everything thouroughly and clearly! This setup works wonders for what I was trying to achieve, I do appreciate you taking time out of your day to help me out. ofek163 7 — 5y
Ad

Answer this question