Hello, its been a while since I have posted due to coronavirus and personal road blocks but I am back now!
At the start of 2020 I started working on a story game. It is the first I have ever tried and gotten far enough to want to continue with. Right now I really don’t understand teleporting players to another game.
Whenever you enter one of the elevators (of Elevator1, 2, 3) It will give you a string with the name of that elevator. I am looking to take all players that have that string and teleport them to the game.
I have tried understanding teleporting but it has not helped looking at forums, so please if you could break down steps in which I can go about this, I would be very appreciative!
Note (I also want to send the players ONLY if they have over 4 players)
Hello, Luculence! I did a teleport example for you.
local TeleportService = game:GetService("TeleportService")
local Players = game:GetService("Players")
local PlayersInList = {Players.Player1, Players.Player2} --save all players in a list.
local PlaceId = 0000000
local success, result = pcall(function()
return TeleportService:TeleportPartyAsync(PlaceId, PlayersInList)
end)
if not success then
warn(result)
end
I wrote those in phone, if theres something wrong please tell me.
Aight to pretty much you need to create the script for the Elevators, which means you should type a script that gives the string either by clone or create, also add a debounce to give only 1 string.
Once you have your strings you should get all of them probably using
function stuff(strings)
for a,b in pairs(game.workspace:GetAllDescendants)
if b.name = "Elevator1" then
if #b == 4 then
--teleport script--
end
you decide what to do with the functions, also this may be wrong since i can’t test because Linux.
Thank you, I have already made a script for the elevators so once you touch the tp button that takes you from the lobby and puts you in the elevator, you receive the string. I just need to figure out how to put all players that have that certain string, in a table and then teleport them.
I wouldn’t tag them with a string value, definitely easier ways to do it. But with how you set it up, I’d probably do something like this in a loop:
local playersToTeleport = {}
for _,v in pairs(game:GetService("Players"):GetPlayers()) do
local char = v.Character
if char then
if char:FindFirstChild("B") then -- "B" is the name of the string value
playersToTeleport[#playersToTeleport+1] = v
end
end
end
if #playersToTelport >= 4 then
-- teleport code using playersToTeleport
end
Ok I thought about it carefully and understand what you wrote and how it works but, where do I reference the placeid that they teleport to, if I have to?