So in my game there’s two sections, the lobby and the actual map. When players join they’re added to a LobbyTable. I’m also going to have a BattlegroundTable that players get added to when they touch a part. I also have folders in workspace labeled Lobby Spawns & Battlegrounds Spawns each with spawn locations named “LobbySpawn” & “BattlegroundsSpawn”.
Then I’m going to use something similar to this (link below) for having randomized spawn points. I’m going to use the tables so it’ll only spawn them at certain spawns depending on the table they’re in. How can I use this system linked below and check what table they’re in? Then if they’re in that table they’ll spawn at a random spawnpoint labeled for that. For example if a player is in the LobbyTable then they’ll only spawn on the spawn locations labeled “LobbySpawn” located in the Lobby Spawns folder.
Any suggestions or ideas on how to execute this would be extremely appreciated!
It’s best to take it slow to find your solution. In this case, it’s quite simple.
To check if they’re in the table, use table.find to determine if the player is in the lobby table. When found, you can create a variable using math.random(min, max) making the max = number of spawns. using this, you can grab the index to find a random spawn ie table[index] and spawn to that spawn’s location accordingly. Now if the player is not in the lobby, do the exact same method as if you found the player in the table, but instead, loop through the battleground spawn instead.
For the random generator, that link you posted will tell you how to make it.
Yeah I know that, pretty much I could make a function called check(player) then inside it do - if table.find(LobbyTable, player.Name) then. And inside the then part I could run the whole script I just showed but make sure everything is lobby related. So something like this-
function check(player)
if table.find(LobbyTable, player.Name) then
local SpawnPoints = game.Workspace[“Lobby Spawns”]:FindFirstChild(“LobbySpawn”
if not SpawnPoints then
print("Spawnpoints not found")
end
local AvailableSpawnPoints = SpawnPoints:GetChildren()
for i, player in pairs (plrs) do
if player then
character = player.Character
if character then
-- Teleport them
local Pos = math.random(1,#AvailableSpawnPoints)
local SpawnPoint = AvailableSpawnPoints[Pos]
character:FindFirstChild("HumanoidRootPart").CFrame = SpawnPoint.CFrame + Vector3.new(0,10,0)
end
end
end
end
Im pretty sure this would work except for the in pairs part. How do I make it so if a player is in the LobbyTable then the local character = that player and their character or whatever for later in the script where this happens “ character:FindFirstChild(“HumanoidRootPart”).CFrame = SpawnPoint.CFrame + Vector3.new(0,10,0)”? @Dragonfable6000