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

Why is this basic TeleportService script not working?

Asked by 4 years ago

I started with a script I found on the roblox website on the page for TeleportService:TeleportToPrivateServer, and changed it to my ids. Sorry if this is a basic, mistake, I am new to scripting. The code should teleport the player to a separate game, but it does nothing.

local TS = game:GetService("TeleportService")
local Players = game:GetService("Players")

local code = TS:ReserveServer(4456038439) -- Returns a code
local players = Players:GetPlayers() -- Get a list of all players

TS:TeleportToPrivateServer(4456038439,code,players) -- Actually teleport the players

2 answers

Log in to vote
1
Answered by 4 years ago
local TeleportService = game:GetService("TeleportService")
local gameID = 00000000 -- put the second game's game ID here.

function onTouched(hit)
    local player = game.Players:GetPlayerFromCharacter(hit.Parent)
    if player then
        TeleportService:Teleport(gameID, player)
    end
end

script.Parent.Touched:connect(onTouched)
-- This is just a simple teleport that teleports you to another game seprate on roblox, No API's or other vip stuff.
-- IMPORTANT: You cannot teleport to other games within studio.

This should work

0
Thanks, modified it a bit to use TeleportService:TeleportToPrivateServer and discovered that to do that the other game requires to be a place in the game that you were teleported from; thanks for the code by the way, easy to modify off of. proqrammed 285 — 4y
0
np RobloxGameingStudios 145 — 4y
Ad
Log in to vote
0
Answered by 4 years ago
Edited 4 years ago

use this if your teleporting every player. the answer above only works when touching a part.

local TeleportService = game:GetService("TeleportService")
local Players = game:GetService("Players")

local gameID = 0 -- gameid here
local code = TeleportService:ReserveServer(gameID)

for _,players in pairs(Players:GetPlayers()) do
     if players:IsA("Player") then
        TeleportService:Teleport(gameID,code,players)
     end
end
0
Thanks, this works too! proqrammed 285 — 4y
0
:( i wasnt accepted ZorbaTheGreatGreek 59 — 4y
0
I really dont mean to beg, but can u consider taking a look at my issue if its not too much of a hassle (litreally no errors but it dont work) https://scriptinghelpers.org/questions/91802/stat-will-not-add-onto-a-players-speed-along-with-another-number-and-my-coin-wont-collect-properly RobloxGameingStudios 145 — 4y

Answer this question