Model Changes Location When Clicked

  1. What do you want to achieve? Keep it simple and clear!
    I want the door to change orientation to make it look like its open.

  2. What is the issue? Include screenshots / videos if possible!
    I’v managed to make the door change orientation to my desired but I’m facing a problem where the whole model moves its position to what seems to be in the middle of the baseplate

  3. What solutions have you tried so far? Did you look for solutions on the Developer Hub?
    Yes I have and I personally didn’t find anything. I do not know where to start to fix this problem.

Before Clicking:
image

After Clicking:
image

image

local GetDetector = script.Parent.Parent.Door.ClickDetector
local model = script.Parent.Parent

GetDetector.MouseClick:Connect(function()
	
	model.PrimaryPart.CFrame = CFrame.fromOrientation(0,-90,0)
	
end)
1 Like

youre not changing the orientation of the cframe of the door your changing position using cframe orientation, try using cframe.angles. Theres also the new DragDetectors that could better suit your use

1 Like

image
Changed it and still happens. DragDetectors wouldnt suit the game style.

I made a mistake with my explanation, i was saying use cframe.fromOrientation and input it into cframe.Angles somehow, Im still thinking tho hold on let me cook

you need to multiply the door’s primarypart cframe and not set it directly

model:PivotTo(model:GetPivot() * CFrame.Angles(0, -90, 0))
1 Like

yeah i was thinking something along the lines of this i forgot :GetPivot() was real ty

you’re welcome? i guess?

1 Like

CFrame.Angles uses radians and not degrees, he should write it like this:
model:PivotTo(model:GetPivot() * CFrame.Angles(0,math.rad( -90),0)

2 Likes