I am trying to make a collab with my friend but it wont work, I used reserveServer and TeleportToPrivateServer, I did this from a serverscript also this goes through all players is this correct or do I do {player} instead of {players}
local TS = game:GetService("TeleportService")
local players = game.Players:GetPlayers()
script.Parent.Touched:Connect(function(h)
local player = game.Players:GetPlayerFromCharacter(h.Parent)
if player then
local code = TS:ReserveServer(myfriendgameID)
TeleportService:TeleportToPrivateServer(myfriendgameID,code,{players})
end
end)
I assume you are trying to teleport the player who touched the parent, if so, it should just be {player} as you are trying to teleport the player who touched it.
local TeleportService = game:GetService('TeleportService')
TeleportService:TeleportAsync(PlaceId, {plr1, plr2, plr3})
This will teleport plr1, plr2 and plr3 all to the given game
The difference between TeleportAsync and Teleport is that TeleportAsync can teleport multiple players at once where Teleport can only do one at a time
local DataStoreService = game:GetService("DataStoreService")
local TeleportService = game:GetService("TeleportService")
local ServerAccessCodes = DataStoreService:GetDataStore("ReservedServerAccessCodes")
-- Teleport the player to a reserved server
local teleportOptions = Instance.new("TeleportOptions")
teleportOptions.ShouldReserveServer = true
script.Parent.Touched:Connect(function(h)
local player = game.Players:GetPlayerFromCharacter(h.Parent)
if player then
local teleportResult = TeleportService:TeleportAsync(MYFRIENDSGAMEID, {player}, teleportOptions)
-- Save the ReservedServerAccessCode from the TeleportResult instance
ServerAccessCodes:SetAsync(teleportResult.PrivateServerId, teleportResult.ReservedServerAccessCode)
-- To retrieve the access code (can only be done from in the reserved server)
local accessCode = game.PrivateServerId ~= "" and ServerAccessCodes:GetAsync(game.PrivateServerId)
end
end)
local Teleportservice = game:GetService("TeleportService")
script.Parent.Touched:Connect(function(h)
local plr = game.Players:GetPlayerFromCharacter(h.Parent)
if plr then
Teleportservice:Teleport(friendgameid,plr)
end
end)
You should not need to own the game you’re teleporting too no
One thing you do need is to have ‘Allow Third Party Teleports’ enabled in the game settings
Its in Game Settings > Security
Are you trying to teleport from in Studio? Because if you are, you should publish your changes to Roblox and join the live game and try again. You can’t teleport in Studio.