Round system help

I am trying to get my game to chose 1 player out of all the players, and make them an “overseer”
and overseer has a different camera angle and can use enemy spawners.

My problem is that the game chooses and overseer, but changes the camera angle and team for every player, can anybody help me figure out why

Main Script (Script inside workspace)

local players = {}
wait(3)

function ChooseOverSeer()
	for i,v in pairs(game.Players:GetChildren()) do
		table.insert(players, v.Name)
	end
	
	for index = 1, #players do
		print(index, players[index])
		local num = math.random(1, #players)
		print(num)
		player = game.Players:FindFirstChild(players[num])
		print(player)
		player.TeamColor = game.Teams.Overseer.TeamColor
		game.ReplicatedStorage.makeover:FireClient(player)
	end
end

function RemoveOldSeer()
	game.ReplicatedStorage.removeover:FireAllClients()
	for i,v in pairs(game.Players:GetChildren()) do
		v.TeamColor = game.Teams.Players.TeamColor
	end
	player = nil
end

while true do
	local msg = Instance.new("Message")
	msg.Parent = workspace
	msg.Text = "Choosing new overseer..."
	wait(2)
	msg:Destroy()
	ChooseOverSeer()
	local msg = Instance.new("Message")
	msg.Parent = workspace
	msg.Text = "New Overseer: " .. tostring(player)
	wait(2)
	msg:Destroy()
	wait(10)
	RemoveOldSeer()
	local msg = Instance.new("Message")
	msg.Parent = workspace
	msg.Text = "Round Over"
	wait(3)
	msg:Destroy()
end

Local Script (inside starter player scripts)

local event = game.ReplicatedStorage.makeover
local event2 = game.ReplicatedStorage.removeover
local CurrentCamera = game.Workspace.CurrentCamera
wait(2)
local player = game.Players.LocalPlayer

event.OnClientEvent:Connect(function()
	CurrentCamera.CameraType = Enum.CameraType.Scriptable
	CurrentCamera.CFrame = game.Workspace.overseercamera.CFrame
	CurrentCamera.CameraSubject = workspace.Baseplate
	
	for i,v in pairs(workspace.spawners:GetDescendants()) do
		if v:IsA("Part") then
			v.Transparency = 0.7
		else
			if v:IsA("ClickDetector") then
				v.MaxActivationDistance = 100
			end
		end
	end
end)

event2.OnClientEvent:Connect(function()
	CurrentCamera.CameraType = Enum.CameraType.Follow
	CurrentCamera.CFrame = player.Character.HumanoidRootPart.CFrame
	CurrentCamera.CameraSubject = player.Character
	for i,v in pairs(workspace.spawners:GetDescendants()) do
		if v:IsA("Part") then
			v.Transparency = 1
		else
			if v:IsA("ClickDetector") then
				v.MaxActivationDistance = 0
			end
		end
	end
end)

sorry if this was a bit messy im new to the forum and this is actually my 2nd post

@wait2008, this loop will be repeated for all Player, so logically he will also do the makeover:FireClient for each player and change the camera for all of them (And make all Player to a Overseer). Say you use this script and in the game you have two players, the game will repeat the code in here 2 times, that there are two players. A tip: DO FORGoT THE FOR LOOP AND NOT USE IT IN THESE CASES (So in cases where you only have to choose one player.)!!!
The solution would be better:

1 Like

Basically what I did was pick a random player and then assign that teamcolor to it!

1 Like