Ad
Log in to vote
0

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

Asked by 1 year 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 1 year 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).

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

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

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

Insert a server script into StarterCharacterScripts (in StarterPlayer).


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

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

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

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 — 1y
Ad

Answer this question