Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

How to stop Tween Service from changing orientation?

I have this code I found on the DevForms, however when I execute the code the model goes into a random orientation rather than a straight tween.

local function tweenModel(model, CF)
	local CFrameValue = Instance.new("CFrameValue")
script.Parent.Cash.PrimaryPart = MainPart
	CFrameValue.Value = model:GetPrimaryPartCFrame()

	CFrameValue:GetPropertyChangedSignal("Value"):Connect(function()
		model:SetPrimaryPartCFrame(CFrameValue.Value)
	end)
	
	local tween = tweenService:Create(CFrameValue, info, {Value = CF})
	tween:Play()
	
	tween.Completed:Connect(function()
		CFrameValue:Destroy()
	end)
end

I execute the function with this:

		tweenModel(MainPart.Parent, CFrame.new(script.Parent.Main_.Position))

This is what happens

How can I fix the problem so it evenly tweens out properly?

1 comment

0

For this part (script.Parent.Main_.Position) make sure it's orientation is the same as the primary part's, also note, if you set the orientation in the script, it will act like setting position, and may put it on top of the register

1 answer

CFrames also store orientation. If you only want to use the position, you use Vector3s, like this:

tweenModel(MainPart.Parent, Vector3.new(script.Parent.Main_.Position)

This discussion is preserved as it was. New answers, comments, and votes are closed.