How to make an obby queue

Im making a stage-based multiplayer obby game, first stage all players in the queue, players go one by one to complete the stage. those who pass move on to the next stage and etc until they reach the final stage.

I was wondering how I should structure this system, like where would I put all my connections for .touched if a player touches a fail-part (makes them fail the stage) etc and in general how it should be

1 Like

i’ve made you a server script to help with this system, I reccommend if the player fails just reset their character. also sorry if you find the script buggy, i havent really been able to test it, its just supposed to be a start anyways.

local order = {}
local picked = {}
local nowChoosing
local i = 1 -- current

function queue()
	for i, v in pairs(game.Players:GetPlayers()) do
		print(v.Name)
		repeat 
			nowChoosing = math.random(1,#game.Players:GetPlayers()) 
		until not table.find(picked, nowChoosing)	
		
		order[nowChoosing] = v.Name
		picked[nowChoosing] = nowChoosing
		
		print(v.Name..": "..nowChoosing)
		print(picked)
	end
end

function gameSystem()
	
	repeat
		i = (i % #order) + 1
	until order[i] -- current player
	
	-- function
end

game.Players.PlayerAdded:Connect(function(plr)
	print(plr.Name)
	repeat 
		nowChoosing = math.random(1,#game.Players:GetPlayers()) 
	until not table.find(picked, nowChoosing)	

	order[nowChoosing] = plr.Name
	picked[nowChoosing] = nowChoosing

	print(plr.Name..": "..nowChoosing)
	print(picked)
end)

game.Players.PlayerRemoving:Connect(function(plr)
	if plr.Name == order[i] then
		gameSystem()
	end
	table.remove(picked, table.find(order, plr.Name))
	table.remove(order, table.find(order, plr.Name))	
end)

game.Players[order[i]].Character:WaitForChild("Humanoid").Died:Connect(function()
	gameSystem()
end)

-- test
wait(3)
queue()
1 Like

^^^ when they touch a fail part just use touched.Parent.Humanoid:TakeDamage(touched.Parent.Humanoid.MaxHealth)

1 Like