I'm working on my own custom placement system, and I thought it would be nice to have the model smoothly move between points with the mouse. I am struggling trying to figure out how to move the whole model. My current code is:
local TweenService = game:GetService("TweenService") local TI = TweenInfo.new(0.05, Enum.EasingStyle.Quad) local newTween = TweenService:Create(currentModel.PrimaryPart, TI, {CFrame = cf}) newTween:Play()
Please note, I did not show the full code here. CurrentModel is the model I am trying to move. cf is the Frame I am trying to move it to.
The problem is, this ONLY moves the primary part of the model. Can someone help?
Try using TweenService:GetValue() in combination with a loop that calls the method SetPrimaryPartCFrame() with a lerped cframe instead!
local TweenService = game:GetService("TweenService") local Time = time() --Gets the starting value of time. local Total = 1 --How many seconds till completion local Model = workspace.Model --Location of model local Start = Model:GetPrimaryPartCFrame() --Starting cframe to lerp with. local End = CFrame.new() --End cframe to lerp to. while time() - Time <= Total do --Will keep looping until beyond timeframe local TI = TweenService:GetValue((time() - Time)/Total, Enum.EasingStyle.Quad, Enum.EasingDirection.In) --Gets the value for which to lerp the cframe with. local CFrame2 = Start:Lerp(End,TI) --Gets the CFrame between start and end Model:SetPrimaryPartCFrame(CFrame2) --Sets the model's CFrame. wait() --Makes sure the game doesn't crash. end
Mhhhhh... i have done something like this some time ago and did not work too and that's stupid imo.
Anyways what you could do to fix it keep the primary part anchored and for other parts use Weld Constraints to weld them to the primary part, also make sure they are not anchored.