I have a spectating script I made, but after you click on it it just says "close" but nothing else works? Here's the script:
local camera = game.Workspace.CurrentCamera
local on = false
script.Parent.MouseButton1Down:connect(function()
if on == false then
for i,v in pairs(game.Players:GetPlayers()) do
if v.InGame.Value == true then
camera.CameraType = "Attach"
camera.CameraSubject = v.Character.Head
script.Parent.Text = "Close"
game.Players.LocalPlayer.PlayerGui.timer.Frame.Visible = false
game.Players.LocalPlayer.PlayerGui.tp.TextButton.Visible = false
game.Players.LocalPlayer.PlayerGui.spect.Frame.Visible = true
on = true
end
end
end
if on == true then
game.Players.LocalPlayer.PlayerGui.timer.Frame.Visible = true
game.Players.LocalPlayer.PlayerGui.tp.TextButton.Visible = true
game.Players.LocalPlayer.PlayerGui.spect.Frame.Visible = false
camera.CameraType = "Custom"
camera.CameraSubject = game.Players.LocalPlayer.Character.Humanoid
end
end)

4 comments
This is in a LocalScript, inside a Textbutton, inside a ScreenGui, inside the StarterGui.
Well like I said, you're trying to change one person's camera to every player's head, and it just keeps getting changed as the loop goes through all the players. Your going to need to pick 1 player to change the camera to accordingly and maybe make it so the players can scroll through them to spectate.
How would I make it go through one player at a time? I know how to make it pick a random player, but how can I make it scroll through?
If I were you, I would put everyone that is spectatable into a table, and then when the person clicks a button or something it will go through that table and spectate that specific person.