I made the camera rotate around the part but i don't know how to make a button that would return the camera back to the player and let the player control the camera as he wishes.
i use this code to rotate the camera around the part ``local target = workspace.Part local camera = workspace.CurrentCamera camera.CameraType = Enum.CameraType.Scriptable camera.CameraSubject = target local angle = 0
while wait()do camera.CoordinateFrame = CFrame.new(target.Position) --Start at the position of the part * CFrame.Angles(0, angle, 0) --Rotate by the angle * CFrame.new(0, 3, 10) --Move the camera backwards 5 units angle = angle + math.rad(0.1) -- speed of rotation
end
Hi, assuming your using a localscript to change the players camera. This script should reset the camera.
EDIT2: [This should fix most issues]
local target = workspace.Part local camera = workspace.CurrentCamera camera.CameraType = Enum.CameraType.Scriptable camera.CameraSubject = target local angle = 0 while wait() do camera.CoordinateFrame = CFrame.new(target.Position) --Start at the position of the part * CFrame.Angles(0, angle, 0) --Rotate by the end
That is your current script and at it's state it just continuously rotates the camera, so I believe that you can use a global variable to solve this
(This is the gui script)
-- once again used in a localscript local button = script.Parent -- change this to where your gui button is local cam = game.Workspace.CurrentCamera shared.camRotate = false button.MouseButton1Down:connect(function() cam.CameraSubject = game.Players.LocalPlayer.Character.Humanoid cam.CameraType = "Custom" shared.camRotate = true end)
(This is in your cam rotate script)
local target = workspace.Part local camera = workspace.CurrentCamera camera.CameraType = Enum.CameraType.Scriptable camera.CameraSubject = target local angle = 0 while shared.camRotate == false do wait() camera.CoordinateFrame = CFrame.new(target.Position) --Start at the position of the part * CFrame.Angles(0, angle, 0) --Rotate by the end
Hopefully that fixes the issue