How can I assign a player a role from the table roles, and then remove that role from the table after it has been assigned, so 2 players cannot have the same role. Thanks!


game.ReplicatedStorage.WaitingTeam.OnServerEvent:Connect(function(plr)
local piwt = {}
local pig = {}
table.insert(piwt,plr)
if #piwt == 1 then
	for i, v in pairs(piwt) do
	     table.insert(pig,v)
	end
	for i, v in pairs(pig) do
		if v == plr.Name then
			
		local roles = {"Werewolf","Seer","Archer","Cupid","Banana Doctor","Villager","Bodyguard"}
-- Here it would be assigned
			game.ReplicatedStorage.GameBegins:FireClient()
		end
	end
	
end
game.Players.PlayerRemoving:Connect(function(p)
for i, v in pairs(piwt) do
	if v == p then
		table.remove(piwt,i)
	end
end
for i, v in pairs(pig) do
	if v == p then
		table.remove(pig,i)
		end
		end
	
end)

1 comment

0

Alright you can't keep asking us for stuff. You'll have to try first