So I tried goofing around with this code but still couldnt figure out how to do this.
local connect = run.RenderStepped:Connect(function()
local np = Vector2.new(mouse.X,mouse.Y)
local center = Vector2.new(camera.ViewportSize.X/2, camera.ViewportSize.Y/2)
local difference = np - center
local outcome = Vector2.new(difference.Y/center.Y, (difference.X/center.X)*maxDegree)
camera.CFrame = CFrame.Angles(-outcome.X, -outcome.Y,0) + workspace.Cameras:FindFirstChild(location).Position
end)
What this code is rotates a part in the directions of the players mouse. The parts orientation is (0,0,0) at default. If I was to change the direction the default orientation is when the script starts working it still faces (0,0,0) at default. How can I make it so it rotates around the base orientation instead of always just (0,0,0)
You’d get the position of the mouse and return a new coordinate frame with an origin point of wherever the camera part is, and have it face towards the position of the player’s mouse.
local player = game.Players.LocalPlayer
local mouse = player:GetMouse()
local Camera = workspace.CurrentCamera
Camera.CameraType = Enum.CameraType.Scriptable
Camera.CFrame = CFrame.lookAt(OriginPosition, PositionToLookAt)
In this case the lookat position would be mouse.Hit.Position
Yes this would work but then you can look everywhere, I only want you to be able to look in certain directions by X amount of degrees. Thats what the code rn does