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.
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).
1 | script.Parent.MouseButton 1 Click:Connect( function () |
2 | game.ReplicatedStorage.Teleport:FireServer() -- fires server event |
3 | script.Parent.Parent.Visible = false -- makes the frame invisible |
4 | end ) |
Insert the script below into the button that declines the TP offer (It's a local script).
1 | script.Parent.MouseButton 1 Click:Connect( function () |
2 | script.Parent.Parent.Visible = false -- makes frame invisible |
3 | end ) |
Insert a server script into StarterCharacterScripts (in StarterPlayer).
1 | while 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.
1 | game.ReplicatedStorage.Teleport.OnServerEvent:Connect( function (player) |
2 | local char = player.Character |
3 | local position = Vector 3. 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(Vector 3. new(position)) -- way to teleport humanoids |
6 | end |
7 | end ) |
Hope this helped!! :D