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

How do i spectate only for players in the playing team?

Hi I've watched this youtube tutorial

https://youtu.be/t0-mymtOu_8

I have a team in my game, which is lobby and playing, so I just want to spectate to the playing team not all players, is there a way?

1 comment

0

You can make a table. Then loop through all the players in the playing team and put those players in that table. Then once you are spectating then you should spectate from the table which only consists of the players who are in the playing team.

1 answer

This is from the script provided from the video you sent:

  • Look over line 39 in the script below.
local frame = script.Parent

local open = frame.Parent.Open

local close = frame.Parent.Close

local specLabel = frame.Parent.SpecLabel

local player = game.Players.LocalPlayer



frame.Visible = false

close.Visible = false

specLabel.Visible = false



local function spec()

	frame.Visible = not frame.Visible

	

	for _, button in pairs(frame:GetChildren()) do

		if button:IsA('TextButton') then

			button:Destroy()

		end

	end

	

	for _, plr in pairs(game.Teams["Playing"]:GetPlayers()) do -- This is the part that needs change 

		if plr.Name ~= player.Name then

			local name = Instance.new('TextButton')

			name.Parent = frame

			name.Text = plr.Name

			name.TextScaled = true

			name.MouseButton1Click:Connect(function()

				local person = game.Players:FindFirstChild(name.Text)

				game.Workspace.CurrentCamera.CameraSubject = person.Character

				specLabel.Visible = true

				specLabel.Text = 'Spectating '..name.Text

				frame.Visible = false

				close.Visible = true

			end)

		end

	end

end



close.MouseButton1Click:Connect(function()

	game.Workspace.CurrentCamera.CameraSubject = player.Character

	specLabel.Visible = false

	close.Visible = false

end)



open.MouseButton1Click:Connect(spec)

This discussion is preserved as it was. New answers, comments, and votes are closed.