Spectate is not working

Spectate script:

local Players = game:GetService("Players")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Functions = ReplicatedStorage.Functions

local Camera = workspace.CurrentCamera


local Player = Players.LocalPlayer
local Character = Player.Character or Player.CharacterAdded:Wait()
local Humanoid = Character:WaitForChild("Humanoid")
--gui
local SpectateGui = script.SpectateGui
local SpectateButton = SpectateGui.SpectateButton
local Spectator = SpectateGui.Spectator

local Left = Spectator.Left
local Right = Spectator.Right
local PlayerName = Spectator.PlayerName
--

local function Swap(player)
	local character = player.Character or player.CharacterAdded:Wait()
	local humanoid = character:FindFirstChild("Humanoid")
	PlayerName.Text = player.Name
	Camera.CameraSubject = humanoid
end

SpectateButton.MouseButton1Up:Connect(function()
	Spectator.Visible = not Spectator.Visible
	if Spectator.Visible == true then
		local player = Functions.Spectate:InvokeServer("Open")
		print(player)
		if player then
			print("Success in opening spectate")
			Camera.CameraType = Enum.CameraType.Scriptable
			Swap(player)
		end
	else
		Camera.CameraSubject = Humanoid
		Camera.CameraType = Enum.CameraType.Custom
	end	
end)

Left.MouseButton1Up:Connect(function()
	local player = Functions.Spectate:InvokeServer("Left")
	if player then
		Swap(player)
	end
end)

Right.MouseButton1Up:Connect(function()
	local player = Functions.Spectate:InvokeServer("Right")
	if player then
		Swap(player)
	end
end)


Player.AttributeChanged:Connect(function(attribute)
	if attribute == "Round" then
		if Player:GetAttribute("Round") == true then
			SpectateGui.Enabled = false
			Spectator.Visible = false
		elseif Player:GetAttribute("Round") == false and Functions.Spectate:InvokeServer("Round") == "Success" and Player:GetAttribute("Joined") == nil then
			SpectateGui.Enabled = true
		elseif Player:GetAttribute("Round") == nil then
			SpectateGui.Enabled = false
			Spectator.Visible = false
		end
	end
end)

In the swap function I am trying to the set the Camera’s CameraSubject to another player’s humanoid, but it’s not changing the position, relativity or anything of the camera. Only the effects of Enum.CameraType.Scriptable are effecting the camera. Should the humanoid come from the server?

It works, just not with Enum.CameraType.Scriptable for some reason.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.