I honestly have no idea what I tried doing at the bottom, it's my first time ever using camera manipulation which explains why it isn't working. The part where it changes the name works, but where it's supposed to follow their Humanoid isn't working whatsoever. I'm not getting an error either. Any help would be appreciated and I would like to understand how to make it move between the players.
Error: Players.Player2.PlayerGui.SpectateGui.LocalScript:62: attempt to index field '?' (a nil value).
cam = workspace.CurrentCamera
local gui = script.Parent
local players = game:GetService("Players")
local bar = gui:WaitForChild("Bar")
local name = bar:WaitForChild("Name")
local nxt = bar:WaitForChild("Next")
local prv = bar:WaitForChild("Previous")
local button = gui:WaitForChild("Button")
local open = false
local openinterval = 3
possibleplayers = {}
playercount = 0
local function playerstable()
for _, player in pairs(players:GetPlayers()) do
if player.Name == name.Text then
return
else
table.insert(possibleplayers, player)
end
end
end
button.MouseButton1Click:Connect(function()
if not open then
bar:TweenPosition(UDim2.new(0.5, 0, 0.85, 0), "Out", "Quad", 1.2)
wait(openinterval)
open = true
elseif open then
bar:TweenPosition(UDim2.new(0.5, 0, 1.05, 0), "In", "Back", 1.2)
wait(openinterval)
open = false
end
end)
nxt.MouseButton1Click:Connect(function()
local allplayers = players:GetPlayers()
local playernumber = playerstable()
if cam.CameraSubject == possibleplayers[#possibleplayers].Character:FindFirstChild("Humanoid") then
cam.CameraSubject = possibleplayers[1].Character:FindFirstChild("Humanoid")
else
cam.CameraSubject = possibleplayers[playercount + 1].Character:FindFirstChild("Humanoid")
end
name.Text = players:GetPlayerFromCharacter(cam.CameraSubject.Parent).Name
end)
nxt.MouseButton1Click:Connect(function()
local allplayers = players:GetPlayers()
local playernumber = playerstable()
if cam.CameraSubject == possibleplayers[#possibleplayers].Character:FindFirstChild("Humanoid") then
cam.CameraSubject = possibleplayers[1].Character:FindFirstChild("Humanoid")
else
cam.CameraSubject = possibleplayers[playercount - 1].Character:FindFirstChild("Humanoid")
end
name.Text = players:GetPlayerFromCharacter(cam.CameraSubject.Parent).Name
end)

4 comments
To make it move between characters, I would suggest using the Interpolate function. http://wiki.roblox.com/index.php?title=API:Class/Camera/Interpolate
They give no example on the Interpolate wiki...
No, all you need is to change camera subject.
I was assuming by move he meant that he wanted to do it differently (smooth gliding between each position) than switching the camera subject. My answer is what I am guessing works for simply switching like hiimgoodpack says.