Help With Spectating System

Ok, So, I’m trying to make a spectating system where when you click the UI you can see from a part, and when you click the UI again your camera is normal.

At the moment, I can spectate, but I can’t stop.
My current code is:

local MANAGER = script
local FRAME = MANAGER.Parent

local Player = game.Players.LocalPlayer
local Character = Player.Character or Player.CharacterAdded:Wait()
local Camera = workspace.CurrentCamera 

local Spectate = FRAME:WaitForChild("_SPECTATE")

local Spectating = false
Spectate.MouseButton1Click:Connect(function()
	if Spectating == false then
		repeat wait()
			Camera.CameraType = Enum.CameraType.Scriptable
		until Camera.CameraType == Enum.CameraType.Scriptable
		Spectating = true
		Camera.CFrame = workspace.CameraPart.CFrame

	else
		Spectating = false
		Camera.CFrame = Character:WaitForChild("Head").CFrame
		Camera.CameraType = Enum.CameraType.Fixed
	end
end)

Solved by RaxelRbx in Post no.2

Try setting the Cameras CameraSubject to the humanoid of the character.

Try this:

local MANAGER = script
local FRAME = MANAGER.Parent

local Player = game.Players.LocalPlayer
local Character = Player.Character or Player.CharacterAdded:Wait()
local Camera = workspace.CurrentCamera 

local Spectate = FRAME:WaitForChild("_SPECTATE")

local Spectating = false
Spectate.MouseButton1Click:Connect(function()
	if Spectating == false then
		repeat wait()
			Camera.CameraType = Enum.CameraType.Scriptable
		until Camera.CameraType == Enum.CameraType.Scriptable
		Spectating = true
		Camera.CFrame = workspace.CameraPart.CFrame

	else
		Spectating = false
		Camera.CFrame = Character:WaitForChild("Head").CFrame
		Camera.CameraType = Enum.CameraType.Fixed
	end
end)local MANAGER = script
local FRAME = MANAGER.Parent

local Player = game.Players.LocalPlayer
local Character = Player.Character or Player.CharacterAdded:Wait()
local Camera = workspace.CurrentCamera 

local Spectate = FRAME:WaitForChild("_SPECTATE")

local Spectating = false
Spectate.MouseButton1Click:Connect(function()
	if Spectating == false then
		repeat wait()
			Camera.CameraType = Enum.CameraType.Scriptable
		until Camera.CameraType == Enum.CameraType.Scriptable
		Spectating = true
		Camera.CFrame = workspace.CameraPart.CFrame

	else
		Spectating = false
		
		Camera.CameraType = Enum.CameraType.Follow
	end
end)

@JohnsonBlu
How would I do that?

maybe

Camera.CameraSubject = Character.Humanoid
?

Oop! just found how to do it! i used the wrong camera mode.
I was ment to use:

enum.cameratype.Orbital

local MANAGER = script
local FRAME = MANAGER.Parent

local Player = game.Players.LocalPlayer
local Character = Player.Character or Player.CharacterAdded:Wait()
local Camera = workspace.CurrentCamera 

local Spectate = FRAME:WaitForChild("_SPECTATE")

local Spectating = false
Spectate.MouseButton1Click:Connect(function()
	if Spectating == false then
		repeat wait()
			Camera.CameraType = Enum.CameraType.Scriptable
		until Camera.CameraType == Enum.CameraType.Scriptable
		Spectating = true
		Camera.CFrame = workspace.CameraPart.CFrame

	else
		Spectating = false
		Camera.CFrame = Character:WaitForChild("Head").CFrame
		Camera.CameraType = Enum.CameraType.Orbital  --<--- Fix was here
	end
end)
2 Likes

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