I cannot use
Model.PrimaryPart.Position
-because that doesn't bring welded parts with it. I also cannot use
Model:SetPrimaryPartCFrame
-because I need to move the model in a tween. (Unless that's possible- but I don't think so)
So I'm currently using:
--Position I'm moving the part to, (Works great) local MouseHitRounded = CFrame.new(math.round(Mouse.Hit.Position.X/grid)*grid, math.round(Mouse.Hit.Position.Y/grid)*grid, math.round(Mouse.Hit.Position.Z/grid)*grid) --Tween itself with CFrame.Angles, (Not so great) local Tween = TS:Create(placingpart, TweenInfo.new(0.2, Enum.EasingStyle.Quart, Enum.EasingDirection.Out), {CFrame = CFrame.new(MouseHitRounded.X,MouseHitRounded.Y,MouseHitRounded.Z) * CFrame.Angles(0,0,0)}) Tween:Play() Tween.Completed:Wait()
I've also tried
local Tween = TS:Create(placingpart, TweenInfo.new(0.2, Enum.EasingStyle.Quart, Enum.EasingDirection.Out), {CFrame = CFrame.new(MouseHitRounded.X,MouseHitRounded.Y,MouseHitRounded.Z) * CFrame.Angles(math.rad(placingpart.Orientation.X), math.rad(placingpart.Orientation.Y),math.rad(placingpart.Orientation.Z)))}) --^^ (All on the same line, ScriptingHelpers was glitching so I had to split it up)
But that creates weird glitches where the part will bounce rotations back and forth.
Because I'm teleporting the part to the player's mouse, the code constantly runs- if that changes anything.
There are numerous threads with this same question that I've looked at, but the threads I've found haven't been under the same conditions. I've been stuck on this for a few days. Any help would be much appreciated. <3
CFrame.new(Vector3.new(0,0,0))
that only does position. not rotation.
i have come with a script a week ago that tweens models, see if this is any use
local ts = game:GetService("TweenService") local rs = game:GetService("RunService") function tween(obj, goal, es, ed, time) --uses ts:GetValue to "tween" if not obj.PrimaryPart then error("No primarypart, can't proceed") end local es = if es ~= nil then es else Enum.EasingStyle["Bounce"] local ed = if ed ~= nil then ed else Enum.EasingDirection["In"] local start = os.clock() local initial = obj.PrimaryPart.CFrame --initial position while true do rs.Heartbeat:Wait() local delta = math.clamp( (os.clock() - start)/time, 0, 1) --gets delta (to use with ts:GetValue()) if delta == 1 then print("finished") obj:SetPrimaryPartCFrame(goal) return end obj:SetPrimaryPartCFrame(initial:lerp(goal, ts:GetValue(delta, es, ed))) end end
about the "keeping orientation" i think you could just use a constant orientation vector3