Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

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

Asked by 3 years ago

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?

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. Soban06 410 — 3y

1 answer

Log in to vote
0
Answered by 3 years ago
Edited 3 years ago

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)
Ad

Answer this question