local Players = game.Players:GetPlayers()
local Num = 1
function Spectate()
if Players[Num] ~=nil then
game.Workspace.CurrentCamera.CameraSubject = Players[Num].Character.Humanoid
script.Parent.Parent.T.Text = "Spectating : " ..Players[Num].Name
Num = Num + 1
elseif Players[Num] == nil then
Num = 1
end
end
script.Parent.MouseButton1Click:connect(Spectate)
while wait() do
Players = game.Players:GetPlayers()
end
Extremely short. I bet other toggle spectates are alot more advanced. Sometimes the most simple code can be the most easiest. It goes through the table of players, keeps adding + 1 to the table, if it ever returns nil, it goes back at the beginning, and the cycle resets.
Neat, huh? |