So I'm basically trying to make a reserved server teleport more than one player, note I'm using a table and when I touch the part it inserts the player into the table it then teleports you into one of the seats, and teleports you to another game of mine. So what i do is i make it so that it reserves a server, and teleports the table of players to the reserved server, I'm quite confused as it teleports all the players in the table to a separate private server can anyone help?
Here is the code:
local Car = game.Workspace.Car1 -- Change "Car1" to the name of your car
local Seats = game.Workspace.Car1.Seats:GetChildren() -- Locates the Group of seats in your car
local Gui = script.Parent:FindFirstChild("ExitButton") -- Locates the Exit Button in the Teleport Part
local Gui2 = script.Parent:FindFirstChild("LoadingScreen") -- Locates the Exit Button in the Teleport Part
local replicatedStorage = game.ReplicatedStorage
local CarBlock1 = replicatedStorage.CarBlockers.CarBlock1
local teleportService = game:GetService("TeleportService")
local placeId = 4912815848
script.Parent.Touched:Connect(function(hit)
if hit.Parent:FindFirstChild("Humanoid") then
local player = game.Players:GetPlayerFromCharacter(hit.Parent)
local playerTable = {}
wait(1)
table.insert(playerTable, player)
local player = game.Players:GetPlayerFromCharacter(hit.Parent)
if Seats.Occupant == nil then
hit.Parent.Humanoid.JumpPower = 0
hit.Parent.Humanoid.WalkSpeed = 0
player.Character.HumanoidRootPart.CFrame = Seats[math.random(1,#Seats)].CFrame
end
wait(10)
local plr = game.Players.LocalPlayer
local CarBlockClone = CarBlock1:Clone()
CarBlockClone.Parent = workspace
local sitting = Seats.Occupant
hit.Parent.Humanoid.JumpPower = 0
hit.Parent.Humanoid.WalkSpeed = 0
for i = 1,30 do -- Moves the car forward
Car:TranslateBy(Vector3.new(0,0,1))
wait()
end
Gui2:Clone().Parent = player.PlayerGui
local playersInCar = playerTable
local code = teleportService:ReserveServer(placeId)
teleportService:TeleportToPrivateServer(placeId,code,playersInCar)
wait(50)
for i = 1,30 do -- Moves Car Reverse
Car:TranslateBy(Vector3.new(0,0,-1))
wait()
CarBlockClone:Destroy()
end
end
end)
