Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Scripting help Making a Spawn like miner's haven!?! (READ)

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?

1 comment

0

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

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

1

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

1

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

0

thehybrid576 I added you I'm Gonna invite you to team create in a minute

0

thehybrid you literally took what I said a gave him this

0

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.