Rotating a Welded Part

Here is a script for a vfx that I am working on. It clones and welds a crosshair in front of a player, and then rotates it via a tween:

The desired effect is produced, but when the player turns the rotation screws up, as shown in the video: Orientation

Since the part is welded, I cannot tween the CFrame instead of the orientation since that messes it up. I also tried replacing the tween with a repeat loop, which fixes this problem, except the player falls over every 90 degrees (Even though it is massless and RootPriority is -1).


How would I solve either of these issues?

The best you could do, i think, is to weld the bars to the white circle and then rotate the circle, try that

Just tried it, nothing changed

Use WeldConstraints instead. They are much much easier.

What do you mean? I thought I was using WeldConstraints, do they have a property I can use?

No you just set the attachments of the WeldConstraint to attachments in a part and then it will stay welded no matter where you move the part. No scripting necessary.

Yea, the constraints are set to the rootpart and the crosshair right now. My rotating tween gets messed up when the player moves, though.

Oh, I just read the code screenshots. I see you are using WeldConstraints.

Maybe try updating the CFrame in a RenderStepped function.

I tried that. It seems to work, except it completely bugs the player out and they get flung all over the place, basically the same issue as when I tried a repeat loop. Do you know how to stop this?

You can try to tween the weld’s C0 or C1 properties (if C0 is set already, you can use C1 for the tweening)

C0 and C1 are only accessible from the Weld object and not the newer WeldConstraint
C0 and C1 determine the offset between Part0 and Part1, with CFrames. Unlike a WeldConstraint, the offset is not calculated automatically (but I like that :wink:)

you should be able to do something like this

Weld.C0 = CFrame.new(3,0,0) -- I am surprised in your example that you are using the X axis and not the -Z axis
local Tween = TweenService:Create(Weld, SpinTweenInfo, {C1 = CFrame.Angles(math.rad(180,0,0)}) -- Might be the wrong axis? If it is, try the Z axis
Tween:Play()
1 Like

Thank you! This almost works perfectly. I just can’t figure out how to get it to rotate clockwise, no matter what combination of axis I try it just rotates the wrong way. I’ll keep trying and maybe post it as a new problem if I can’t figure it out. Have a great day :slight_smile:

Update: I managed to fix it, I just had to tweak the C0 with some CFrame.Angles so it matched the player’s rootpart. The script works perfectly!

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.