So there has been this game that has recently come out which is called Camping. You are teleported to another server with a group of people who have joined you on a truck. I have been wondering how this is done because I haven't been able to figure it out so far.
I've read almost every page of information on how to do it, but nothing would work for me. Does anyone have an idea of how they do it?
I have attempted this code - (This is not the only code I have attempted. I am having trouble finding the other ones.)
local TeleportService = game:GetService("TeleportService") local DSS = game:GetService("DataStoreService") local DS = DSS:GetGlobalDataStore() local code = DS:GetAsync("ReserveServer") if type(code) ~= "string" then code = game:GetService("TeleportService"):ReserveServer("2575716765") DS:SetAsync("ReserveServer",code) end for i,v in pairs(game.Teams["Team"]:GetPlayers()) do TeleportService :TeleportToPrivateServer(3180151090,code,v) end
I don't know if this is what you are looking for but there are (at least that I know of) 3 kinds of teleport. Teleport inside a place, teleport between places & teleporting between games.
Teleporting all players inside of a place would look something like this: It's from the Roblox dev forum developer.roblox
target = CFrame.new(0, 50, 0) --could be near a brick or in a new area for i, player in ipairs(game.Players:GetChildren()) do --Make sure the character exists and its HumanoidRootPart exists if player.Character and player.Character:FindFirstChild("HumanoidRootPart") then --add an offset of 5 for each character player.Character.HumanoidRootPart.CFrame = target + Vector3.new(0, i * 5, 0) end end
Teleporting between places would look something like this: Taken from roblox dev forum developer.roblox
local TeleportService = game:GetService("TeleportService") local placeID_1 = 408502340 local placeID_2 = 408502380 local function onPartTouch(otherPart) local player = game.Players:GetPlayerFromCharacter(otherPart.Parent) if player then TeleportService:Teleport(placeID_1, player) end end script.Parent.Touched:Connect(onPartTouch)
Then you can also teleport between games: Taken from this thread ScriptingHelpers You cannot access this through the studio though. And in this example, the script is inside a part in workspace.
script.Parent.Touched:Connect(function(player) if player.Parent:FindFirstChild("HumanoidRootPart") then local service = game:GetService("TeleportService"); local place = 20279777; --Voidacity's Script Builder local plr = game.Players:GetPlayerFromCharacter(player.Parent) service:Teleport(place,plr); end end)