I am trying to make a story game and have a question:
When players touches a part it puts them into a vehicle. I want to teleport them to the main game (a different game place).
What I need to do is every time the player touches the part whilst in the vehicle, they join the main story game, it needs to make a new server of the main game and send the players in the vehicle to that server. The reason for that is so no one join in the middle of a story and things get weird. How can I create a new server to send players to, can I even do that?
I tried to teleport people using this script but it does not print anything in the output.
local placeId = 6993807468
local teleportService = game:GetService("TeleportService")
local part = script.Parent
local function getRegionFromPart(part)
return Region3.new(part.Position - (part.Position/2), part.Position + (part.Position/2))
end
local function teleport(partsTable)
for i, v in pairs(partsTable) do
print(v)
local player = game.Players:GetPlayerFromCharacter(v.Parent)
if player then
teleportService:Teleport(placeId, player)
end
end
end
local region = getRegionFromPart(part)
while wait() do
local partsInregion = workspace:FindPartsInRegion3(region, script.Parent)
teleport(partsInregion)
end
You have yet to assign it to partsTable, you’re trying to return partsTable in your teleport function. do something like
local function getRegionFromPart(part)
local partsTable = Region3.new(part.Position - (part.Position/2), part.Position + (part.Position/2))
return Region3.new(part.Position - (part.Position/2), part.Position + (part.Position/2))
end
That would not work. A region is not a table. You have to call the FindPartsInRegion3 function to get a table. The script worked before, it printed the part the region was made from, but once I added the part to the ignore list, it did not print anything.