CamPart Rotation following mouse

hello everyone, so i am very stuck on this one part i want this cam part to rotate to the mouse on Orientation y axis this is what im getting https://gyazo.com/33e295590f33379cb09da8f687defa6d

and here is some of my code i have right now

repeat wait() until game.Players.LocalPlayer and game.Players.LocalPlayer.Character

local camera = workspace.CurrentCamera

local RunService = game:GetService("RunService")

local mouse = game.Players.LocalPlayer:GetMouse()

RunService.RenderStepped:Connect(function()

camera.CFrame = workspace.CamPart.CFrame

workspace.CamPart.Orientation = Vector3.new(0,mouse.hit.y / 30,0)

end)

this is the result i wanted to get
https://gyazo.com/9dbf8e4e3222477c63d5e38cae69f640

if anyone of you can help that would be great!

2 Likes

Hi there, I’m not all too familiar with doing camera mechanics like you’re describing but the issue could be something as simple as maybe you need to pass an x, y and z position on the Vector3.new line. Although, I’m not positive, little things like that can sometimes fly under the radar and be a little bit finicky.

2 Likes

I had encountered a similar issue, and I got a solution in my created topic.
The topic:

2 Likes

I have not tried this before but you can try something like.

camera.CFrame = CFrame.new(camera.CFrame.Position,Vector3.new(camera.CFrame.Position.X,mouse.Hit.Pos.Y,camera.CFrame.pos.Z)

Instead of camera, you can change it to campart.

Maybe this :man_shrugging::

repeat wait() until game.Players.LocalPlayer and game.Players.LocalPlayer.Character

local camera = workspace.CurrentCamera

local RunService = game:GetService("RunService")

local mouse = game.Players.LocalPlayer:GetMouse()

RunService.RenderStepped:Connect(function()

    camera.CFrame = workspace.CamPart.CFrame

    workspace.CamPart.Orientation = Vector3.new(0,mouse.X / 30,0)

end)

Try getting the mouse’s X position on the screen and setting it to the y-axis rather than the y position of the mouse’s hit

1 Like

I pressed spacebar and it saved the post to the topic…

thanks everyone i will try them and and mess with the code and see what get!

i found a fix due to the issue i was meant to CFrame the camera to the parts pos and then use the mouse to change the rotation

here is the code thanks for everyone that helped me with this!

 Camera.CFrame = part.CFrame
 Camera.CameraSubject = Cursor
 Camera.CameraType = Enum.CameraType.Scriptable
 Camera.CFrame =  CFrame.new(part.Position, Cursor.Hit.p)