I'm working on a game called King Ace, and I made spawns but I want people to spawn in them randomly only 4 people and I don't know how I've tried everything I know and if someone owns that spawn no one else can go there unless that person leaves could someone help with this script?
This is just a choice
What if you put a value in the spawner called taken a BoolValue and then based it off if someone is touching then that value is set to true else it means false and people can spawn there but dont use a actual spawn
To check if the spawns are taken, you can insert a BoolValue called "Taken". Now group all the spawns together in Workspace and sort through each of them using the for loop to check if they are taken and out of the non-taken spawns, spawn the players at a random one. Here is an example of what I am talking about:
--(Server script) local availableSpawns = {} for i,v in pairs(game.Workspace.Spawns:GetChildren()) do table.insert(availableSpawns, v) end for i,v in pairs(game.Workspace.Spawns:GetChildren()) do v.Taken.Changed:connect(function() if v.Taken.Value == true then table.remove(availableSpawns, v) else table.insert(availableSpawns, v) end end) end game.Players.PlayerAdded:connect(function(plr) repeat wait() until plr and plr.Character local spawn = availableSpawns[math.random(1, #availableSpawns)] plr.Character.Torso.CFrame = CFrame.new(spawn.Position) spawn.Taken.Value = true end
I can't make it where when the player leaves, his spawn's "Taken" value will turn to False because I do not know how you want (or will) have the game set up. Hopefully you can figure out the rest!