So I’m trying to create a spawn system like Zo using spawn locations and tables. When a player first loads in they’re added to a LobbyTable meaning they can only spawn on spawn locations named LobbySpawn. Then when a player touches a specific part they’re removed from the LobbyTable and added to the BattlegroundTable. While in this table they’ll only spawn at spawn locations named BattlegroundsSpawn.
I’ve tried multiple methods for trying to do this but to no avail. Any suggestions or ideas on how to execute this is much appreciated!
Pretty much we have 2 tables and 2 sets of spawn locations. 1 table is named LobbyTable, the other is named BattlegroundsTable. 1 set of spawn locations is named LobbySpawn, while the others are named BattlegroundsSpawn. I want it so if a player is in the lobby table then they’ll only spawn at spawn locations named LobbySpawn. Then when a player touches a part they’re removed from the LobbyTable, added to the BattlegroundsTable, and then only spawn at spawn locations named BattlegroundsSpawn.
When a player is added, add them to the lobby table. Check for death, and when they die, wait until they have respawned and then teleport them to a random spawn location.
Let’s assume you have all the spawns in a folder in workspace. When they player has respawned, loop through all spawn points for Spawns,ChosenSpawn in pairs(SpawnsFolder:GetChildren) then assign the player property SpawnLocation to the random spawn chosen. and you have to reload them
For the touching part, remove the player from the Lobbytable and add them to battleground table, then repeat
I hope this helps, and im terrible at explaining ik
Thing is I need players to be able to damage eachother. So let’s say we use teams. I don’t want players on LobbyTeam to be able to damage eachother. But I want players on BattlegroundsTeams to be able to damage eachother
Could you show this in a visual form? Like how would I structure this? I’ve already got the part down about adding them to the lobby table when they join
So we have 2 tables, one named LobbyTable, one named BattlegroundsTable. Then we have 2 folders with spawn locations inside of them. These folders are called Lobby Spawns & Battlegrounds Spawns, the spawn locations inside those folders are named after the folder they’re in (LobbySpawn & BattlegroundSpawn). When a player first joins they’re added to the LobbySpawn table, I want to set it up so if they’re in that table they’ll only spawn at spawn locations named LobbySpawn. Then the rest is easy, when they touch a specific part they’re removed from the lobbyspawn table and added to the battlegroundstable. Then if they’re in the BattlegroundsTable they’ll only spawn at spawn locations named BattlegroundSpawn.
I need help figuring out how to check if a player is in a table (for this example let’s use the LobbyTable). Then if they’re in that table they’ll only spawn at spawn locations with that name (Following the example - if a player is in LobbyTable then they’ll only spawn at spawn locations named LobbySpawn).
local lobbyTable = {}
local lobbySpawns = ---spawnLocationPath:GetChildren()
local touchPart = --touchPart go find it
game.Players.PlayerAdded:Connect(function(plr)
table.insert(lobbyTable, plr)
plr.CharacterAdded:Wait()
local Character = plr.Character
local hrp = Character:FindFirstChild("HumanoidRootPart")
hrp.Position = lobbySpawns[math.random(1, #lobbySpawns].Position
end
touchPart.Touched:Connect(function(other)
if game.Players.GetPlayerFromCharacter(other.Parent) then
table.remove(lobbyTable, table.find(lobbyTable, game.Players.GetPlayerFromCharacter(other.Parent))
end
end)
this is unfinished try this out to see if it works
Alrighty, ill try it right after this - (chat gpt)
local player = game.Players
LobbyTable = {}
game.Players.PlayerAdded:Connect(function(player)
table.insert(LobbyTable, player)
print("Player added to lobby table")
end)
if table.find(LobbyTable, player) then
print("Player is in lobby table")
local spawnFolder = game.Workspace:FindFirstChild("Spawns")
local spawnLocations = spawnFolder:GetChildren()
local filteredLocations = {}
for i, location in ipairs(spawnLocations) do
if location.Name == "LobbySpawn" then
table.insert(filteredLocations, location)
end
end
local spawnLocation = filteredLocations[math.random(1, #filteredLocations)]
player.Character:SetPrimaryPartCFrame(spawnLocation.CFrame)
end
You can use teams, first assign a team like “Lobby” or “Battlegrounds”, then based on the team use math.random() to get a random one, or if you don’t want teams you can simply use the math.random() method and put them in a table manually