How do I change the orientation of a model?

I know this has been asked many times before, but it does not quite seem to be working. To move the model I did

            local it = v.PurchasedObjects.Up
			it.PrimaryPart = it.Body
			it:MoveTo(Vector3.new(x,y,z))

But to rotate it I tried CFrame.

it:PivotTo(it:GetPivot() * CFrame.Angles(math.rad(xro), math.rad(yro), math.rad(zro)))

Since it is a button though, the model just keeps rotating as the event keeps firing. I tried orientation but that did not quite work out. How can I just set it to a certain position when this button is touched?

2 Likes

Isn’t that how it should work? Can you maybe send a video to explain a bit better?

That is how CFrame works I guess, but I just want to change its orientation once and that’s it. Like it’s orientation will be (1,0,90) and I want its orientation to be (30,0,70) instead

Then only fire the event once.

The event fires every single time the block is touched. It is a regen button. I just want to change it’s orientation. I can’t use CFrame and when I used orientation I got errors. Looking for a way to change the whole models orientation.

it:PivotTo(it:GetPivot() * CFrame.Angles(math.rad(xro), math.rad(yro), math.rad(zro)))

Every time you rotate the model, you’re referencing the original position with

:GetPivot()

But… That alters the last rotation set, not set it to a specific rotation.

To set a specific rotation, you wouldn’t account for the current rotation, unless a certain axis is supposed to stay the same or align with something else.

try this:

local debounce = false
local it = v.PurchasedObjects.Up
it.PrimaryPart = it.Body
if not debounce then
   debounce = true -- makes it so it can only run ONCE
   it.PrimaryPart.CFrame = it.PrimaryPart.CFrame*CFrame.Angles(math.rad(xro), math.rad(yro), math.rad(zro))
end

-- if you want to be able to run the event again at any point in time, use debounce = false

orientation doesn’t work because only CFrames that are altered on the primarypart of the model replicate to the rest of the model parts