When you click the button that the script is parented to, it doesn't seem to make the camera normal again. It just keeps circling the part in workspace. Why is this?
local target = workspace.Part local camera = workspace.CurrentCamera camera.CameraType = Enum.CameraType.Scriptable camera.CameraSubject = target local angle = 0 while true do camera.CoordinateFrame = CFrame.new(target.Position) * CFrame.Angles(0, angle, 0) * CFrame.new(0, 0, 20) angle = angle + math.rad(0.8) game:GetService("RunService").RenderStepped:wait() end script.Parent.MouseButton1Down:connect(function() game.Workspace.CurrentCamera.CameraSubject = game.Players.LocalPlayer.Character.Humanoid game.Workspace.CurrentCamera.CameraType = "Custom" end)
Make a variable to control when the while loop runs. Then, make an if statement in the while loop to check if the variable is false.
If the variable is false, run the camera changing code. Else, do nothing.
local target = workspace.Part local camera = workspace.CurrentCamera camera.CameraType = Enum.CameraType.Scriptable camera.CameraSubject = target local angle = 0 local disabled = false while true do if not disabled then camera.CoordinateFrame = CFrame.new(target.Position) * CFrame.Angles(0, angle, 0) * CFrame.new(0, 0, 20) angle = angle + math.rad(0.8) end game:GetService("RunService").RenderStepped:wait() end script.Parent.MouseButton1Down:connect(function() disabled = true game.Workspace.CurrentCamera.CameraSubject = game.Players.LocalPlayer.Character.Humanoid game.Workspace.CurrentCamera.CameraType = "Custom" end)