How to Rotate Welds With C0?

Relatively simple question, I mean

How do I do it?

3 Likes

Weld.C0 *= CFrame.Angles(x, y, z)

4 Likes

what if i wanted it to be offset by a couple studs and also rotated?

To offset it a couple studs, get the part with the weld in it and add this code:

local Part = script.Parent

Part.CFrame *= CFrame.new(xOffset, yOffset, zOffset)

i thought that you could just do this with C0 tho i thought that was the whole point…?
can i not do them at the same time…?

You can do them at the same time, you should just use CFrame.new to offset parts because its easier in my opinion atleast.

I’ll make a script that lets you offset and move parts gimme a sec

local Part = script.Parent
local Weld = Part:FindFirstChildOfClass("Weld")

--[ MAIN ]--
function MoveAndRotate()
	Weld.C0 *= CFrame.Angles(1,0,0)
	Part.CFrame *= CFrame.new(1,0,0)
end
MoveAndRotate()

is there really not a way to just rotate them and offset them all at the same time

like cframe.angles * cframe.new or somnething

As far as I’m concerned, no. But that is the code I use to offset and rotate welded parts at the exact same time.

1 Like

last question, what does *= mean?

You should be able to offset and rotate it like:

C0 = CFrame.new(offset)*CFrame.Angles(rotation)

the *= is just a shorter way of doing Part.CFrame = Part.CFrame * CFrame.new(xOffset, yOffset, zOffset)

random question about this method, whenever i use cframe.angles i have to do the whole math.rad() thing to make it degrees, is there a replacement for .angles that just lets me do it straight to degrees? like is that what euler angles/ axis angles are for? what are they for? help

Not unless you want to use the orientation or rotation property which isnt really very nice to work with in my experience
If it really bugs you you could make your own function that auto converts it or something

do
    local angles = CFrame.Angles
    CFrame.Angles = function(x,y,z)
        return angles(math.rad(x),math.rad(y),math.rad(z))
    end
end

CFrame.new(1,2,3)*CFrame.Angles(90,45,0)

Alright so you can do –

local Weld = dababy -- Put weld path here
Weld.C0 = CFrame.new(OffsetX, OffsetY, OffsetZ) * CFrame.Angles(RotationX, RotationY, RotationZ)

the * means multiplied by
basically you multiply the angle by the offset and it rotates for you.

doing this doesnt seem to rotate the thing it seems to rotate it around the point
so is that a problem
or do i just change the positional offset to account for it

thats what i tried but

refer to this question as well

please define “point”
do you mean a position?

CFrame operations care about order, if you write an offset first, and then a rotated offset, they will be applied in this order, otherwise, if you want to first rotate the part, and then apply the relative xyz offset, you can just do that by placing the operations in that order, in your case: CFrame.Angles(rotation)*CFrame.new(xyz_offset)

9 Likes