Only want 1 part in a model to tween?

I need help tweening ONLY 1 part in the model which is the “Hinge” and it is welded to the “Top”. For some reason only the hinge is moving but the Top is not. Is there anyway to fix this problem?

Question: Do I have to weld all the parts in the model together still?

image

Also, here is my script:

local TweenService = game:GetService("TweenService");
local hinge = script.Parent.Hinge
local prompt = script.Parent.Top.PromptAttachment.Prompt

local Info = 
	TweenInfo.new(
		2,
		Enum.EasingStyle.Quint,
		Enum.EasingDirection.Out,
		1,
		true,
		1
	);

local Goals = {
	Orientation = Vector3.new( 90, 0, 0 );
}

local movePart = TweenService:Create( hinge, Info, Goals );

prompt.Triggered:Connect(function()
	movePart:Play();
end)
1 Like

All parts that you want to move with the hinge must be welded to the hinge or welded to a part that is welded to the hinge. I would also anchor all the parts, don’t worry you can still tween anchored and welded parts.

Do I weld the hinge to the Top or do I weld the Top to the hinge?

Also, here is what happened after what you said
https://i.gyazo.com/f0d52ccffbbb8e34262e52cdd3b4dcb2.mp4

change orientation to cframe, changing position/orientation in the weld do not affect the other part in the weld

I don’t think it matters what order it’s in, as long as it’s welded to the hinge in some way. Also don’t use orientation, use CFrame to rotate things. There are tons of youtube tutorials on it, I can find a few for you if you need.

The reason we don’t use orientation is because it’s going to change it’s world orientation, CFrame will change it’s orientation/position relative to it’s local rotation/position.

I tried, but I think using CFrame moved the positions.

local Goals = {
	CFrame = CFrame.fromEulerAnglesXYZ(0, 90, 0);
}

This is what you want, you might have to play around with it to get it how you need it

EDIT: I should explain what this does.

CFrame is a type of Vector in a way, it uses 3 values x,y,z mainly, there are more but those are matrices not axes. CFrame.fromEulerAnglesXYZ will change orientation locally relative to it’s current CFrame. However inside it you should convert to math.rad() So it would be more like:

local Goals = {
	CFrame = CFrame.fromEulerAnglesXYZ(0, math.rad(5), 0); -- Edit the function as you need
}

It gave me this error.

Oops, I think it’s because I put Orientation instead of CFrame at the first place.

1 Like

Yea check out my edited post to see it correctly, sorry i’m working on 2 hours of sleep working on my own game lol

Ah, so sorry to be such a bother. It moves really weirdly but the orientation changes. Do you know why it is doing it and I think the top should really be moving with it too right?

https://i.gyazo.com/68c5a9f89a321d618e789fac518e8d1a.mp4

No worries, the dev forum is for help.

It’s doing that because I made a mistake, you want to set it like this:

local Goals = {
	CFrame = hinge.CFrame * CFrame.fromEulerAnglesXYZ(math.rad(5), 0, 0); -- Edit the function as you need
}

We multiply the new CFrame by the last CFrame to change it relative to it’s current CFrame, That’s a lot of CFrames but I promise it get’s easier as you learn them more. Basically we’re saying:
I want to change the current CFrame by “this” much.

Basically if you set a CFrame to CFrame.new() it’s the equivalent of saying Vector3.new() but in local space

1 Like

It worked, thank you so much for helping me :smiley: I’ve been struggling with this for the past hour since I’m really new to scripting. Thanks a lot!

Take a look at the edited message to learn how it works

1 Like

I understand it is slightly off-topic to the thread, but I wanted to reply here so that future readers may be less confused. CFrame is very different from Vector3. Vector3 & vectors in general do not have position, they have magnitude and direction (it just so happens that in Roblox Vector3 stems from origin). CFrame is an entire matrix that does have position.

1 Like

I was trying to keep it simple, because this is roblox, Vector3 in roblox refers specifically to position, where you can call the magnitude and direction from the Vector3, in this context CFrame and Vector3 are similar, CFrame is just local position whereas Vector3 is global/world position