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?
Scripting help Making a Spawn like miner's haven!?! (READ)
2 answers
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
2 comments
That makes no sense honestly I want it so as soon as they join it looks for a open thing and it automatically teleports them there
Yes you would do a onplayer added here
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!
3 comments
thehybrid576 I added you I'm Gonna invite you to team create in a minute
thehybrid you literally took what I said a gave him this
I never read yours so don't complain, also Kenley ok, message me on roblox when you are ready, my username is "uwot_m9"
This discussion is preserved as it was. New answers, comments, and votes are closed.

1 comment
Post what you've tried. If you actualy tried everything you'd have had a solution