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))
How can I fix the problem so it evenly tweens out properly?
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)