I’m currently scripting for someone a turret that can move when the player has moved their mouse. However, I can’t seem to be able to make the Turret turn and face the player’s mouse. Whenever I do try, it either does not work at all or the whole plane that the turret is in moves along with the turret. Someone, please help me out.
Here are some screenshots of the model along with my code:
You need a remote event to send the information to the server.
I would recommend to render movement on the original client first, then send the mouse hit to the server, which sends it to each client, and if that client isn’t the original client, render the movement.
Edit: Also, for the CFrame, just do CFrame.new(origin, mouse.Hit.Position)
The thing is, I have already tried to make a remote event that sends over the info to the server. But when I tried actually making use of the info (which was the position of where the mouse hit) and try to change the CFrame of the turret, it either wouldn’t work or the WHOLE plane itself would move.
The turret itself is all anchored. I’m not the best at motors and welds. I to be honest just wanna find a way where the turret will move freely within the X and Y axis without the problem happening in the vid.
This sounds pretty finickey, I would think you’ll run into a lot less issues if you try one of the methods I mentioned above with the turret unanchored.
I don’t think the turret is anchored while the plane is moving. Do you have a WeldScript somewhere in this beast that welds the Parts and Unanchors them?
As stated I’d make the turret unanchored and put it on a HingeConstraint with the Motor set to motor or servo, then use the information from your mouse to spin the motor.
Btw, gorgeous looking B-17!
Well first, that script most likely unanchors all parts that it effects as mentioned by @Scottifly. second, it’s not using weld constraints. This is usually bad but in your case you can use this to your advantage and edit the C0 of the welds.
Just make sure the other parts are weld constrainted to the center part moving in the turret.
To elaborate on the C0 editing, you can change the rotation and position offset of the weld, allowing you to move the welded part when the plane moves, and independently at the same time