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)
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)
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)