--Thanks for using this script
--This script is made by Joriangames/Problox Studio Scripts
--Want to know how to use this? Watch my tutorial: https://youtu.be/T65gtxrukQg

local button = script.Parent.OpenSpectate
local frame = script.Parent.Frame
local title = frame.PlrName
local left = frame.Left
local right = frame.Right
local cam = workspace.CurrentCamera
local num = 1
local plr = game.Players.LocalPlayer

button.MouseButton1Click:Connect(function()
	if frame.Visible == true then
		frame.Visible = false
		title.Text = plr.Name
		cam.CameraSubject = plr.Character.Humanoid
		num = 1
	else
		frame.Visible = true
		title.Text = plr.Name
		cam.CameraSubject = plr.Character.Humanoid
		num = 1
	end
end)

right.MouseButton1Click:Connect(function()
	local players = game.Players:GetPlayers()
	local all = #players
	num = num +1
	if num > all then
		num = 1
	end
	cam.CameraSubject = players[num].Character.Humanoid
	title.Text = players[num].Name
end)

left.MouseButton1Click:Connect(function()
	local players = game.Players:GetPlayers()
	local all = #players
	num = num -1
	if num < 1 then
		num = all
	end
	cam.CameraSubject = players[num].Character.Humanoid
	title.Text = players[num].Name
end)
