Spectate

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.Players:GetChildren()) do

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)