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

Why is it not teleporting a player?

Asked by 5 years ago

I have a multi-place game and want it so you can teleport between places. Right now I use a basic teleportation system and it doesn't work half the time and takes a lot of time when it does. Is there anything to change or to improve on?

local Teleport = game:GetService("TeleportService") 
Teleport:Teleport(ThePlaceId, plr)

This is the teleportation part of the script and the script fires when the player touches a part. The function fires and it makes a teleport GUI open on touch, but the teleportation does not work.

Any help is very useful, thanks!

1 answer

Log in to vote
0
Answered by 5 years ago
Edited 5 years ago

There is a script for this by Roblox but here it is!

  1. local TeleportService = game:GetService("TeleportService")
  2. local ReplicatedStorage = game:GetService("ReplicatedStorage")
  3. local Players = game:GetService("Players")

  4. local playerGui = Players.LocalPlayer:WaitForChild("PlayerGui")

  5. local placeId = 0 -- replace here

  6. local loadingGui = ReplicatedStorage:FindFirstChild("LoadingGui") -- replace here

  7. -- parent the loading gui for this place
    
  8. loadingGui.Parent = playerGui
    
  9. -- set the loading gui for the destination place
    
  10. TeleportService:SetTeleportGui(loadingGui)
    
  11. -- teleport the user
    
  12. TeleportService:Teleport(placeId)
Ad

Answer this question