Cant rotate mortar that is welded to ship

Ok I have a mortar model and its primary part is welded to another part on a ship with WeldConstraint. All the parts in the mortar are welded (WeldConstraint) to its primary part. I want the the mortar to be rotated. (All its parts will rotate as well and offset is relative to the mortar’s primary part.) I cant get the mortar to rotate. Please help.

Ok sorry here is the image

if you use RigidConstraint

https://developer.roblox.com/en-us/api-reference/class/RigidConstraint

then you can rotate the attachment and the morter should rotate

or another option is to use a HingeConstraint

https://developer.roblox.com/en-us/api-reference/class/HingeConstraint

then set the ActuatorType to servo

https://developer.roblox.com/en-us/api-reference/property/HingeConstraint/ActuatorType

and then you can use TargetAngle so the servo rotates to the angle you want

https://developer.roblox.com/en-us/api-reference/property/HingeConstraint/TargetAngle

2 Likes

Ok i set up the rigid constraint but i cant get it to work. I set the cframe of the attachment to the rotation I wanted but the part just suddenly disappeared and was shaking in the air

im not sure how you are setting the CFrame but maybe setting the WorldCFrame might work better ??

https://developer.roblox.com/en-us/api-reference/property/Attachment/WorldCFrame

1 Like

Im sorry. Idk what I just did but it works now. There was something else being welded to the mortar parts. Anyways this is my code

local SteerCFrame = Attachment.CFrame * CFrame.Angles(math.rad(RotationIncrement * VehicleSeat.Steer), 0, 0)
Attachment.CFrame = SteerCFrame
Model:SetPrimaryPartCFrame(Attachment.CFrame)

if your using RigidConstraint all you should need to do is

Attachment.CFrame *= CFrame.Angles(math.rad(RotationIncrement * VehicleSeat.Steer), 0, 0)
1 Like