So i'm trying to make a spectate system on my game. I just looked it up on youtube and found the script to spectate EVERYONE, but I just want people to spectate others on a certain team. The code I got was this:

prev.MouseButton1Click:connect(function()
	wait(0.1)
	local players = game.Players:GetPlayers()
	local num = get()
	if not pcall(function()
		cam.CameraSubject = players[num-1].Character.Humanoid

	end) then
	
	cam.CameraSubject = players[#players].Character.Humanoid

	end
	pcall(function()
		title.Text = game.Players:GetPlayerFromCharacter(cam.CameraSubject.Parent).Name
	end)
end)

I tried to make an if statement before cam.CameraSubject = players[#players].Character.Humanoid that said

if players[#players].Team == "In Fight" then

but that didn't seem to do the trick. Does anyone have any suggestions or anything? Thanks!

4 comments

0

alvinbloxx my boi

0

also since the code uses indexes of the array that :GetPlayers() returns to spectate, then you could do an if statement if that player with that index is in a specific team

0

Is this AlvinBlox?

0

it was yeah