How do I rotate a steering wheel with my my mouse

I’m currently making a car which you operate in first person with interactive buttons and all that. The problem I am having is that I cannot figure out for the life of me how to turn using a steering wheel and your mouse.

I really need help with figuring out how to rotate a steering wheel with my mouse. Thank you for any ideas!

Please tell me if this is breaking any rules or has been posted somewhere else :slight_smile:

If your wanting to detect if the player is moving their mouse left or right, and steer it, you can use this in a LocalScript inside of a gui or playerscripts:

local m = game.Players:GetMouse()
local position = {m.X, m.Y}
m.Move:connect(function()
      if m.X <= position[1] + 2 then
           //put the steering script here
     end
      if m.X >= position[1] - 2 then
            //put the steering script here
      end
end)

Tell me if this doesn’t work.

2 Likes

( Sorry for the late reply I was sleeping )

This does work but I have to be in first person to interact with buttons in the car, so the mouse X stays the same since the mouse is locked in the middle of the screen. ( See pic below )

image
( Note that the “Left” and “Right” buttons are just a replacement to turn for now. )
Thank you so much anyways!

You can make your GUI buttons modal, which will “unlock” the mouse so it can be moved while in first person.

1 Like

I could but I want to click on the steering wheel in first person and be able to drag the steering wheel to rotate left or right.

Thank you so much for replying!

So, you mean you want to be able to disable/enable steering by clicking on the steering wheel?

1 Like

Hey! Here’s what I mean by dragging the wheel with your mouse:

( Note that I just made it spin when I click it to make the effect of actually dragging the wheel left/right )

Thank you so much for helping!

Ah, I don’t have any experience with making draggable 3D objects, so I don’t really know how to do it. Sorry!

1 Like

This can be done by attaching the steering wheel to the car with either a HingeConstraint, Hinge, or anything that can let it spin freely. Afterwards, proceed to do the dragging part, which a tutorial simillar to your situation can be found here.

1 Like