Tweening causes object to become disfigured

Im creating a Tween that causes a car to follow a path to the end. It works fine, but sometimes, for no reason, the car will bug out and look like this

script:

local TweenModule = require(game:GetService(“ReplicatedStorage”):WaitForChild(“TMmoduleV2”))

local PrimaryPart = script.Parent

local WayP = game.Workspace.Waypoints

local d1 = WayP.W1

local d2 = WayP.W2

local d3 = WayP.W3

local d4 = WayP.W4

local d5 = WayP.W5

local TweenService = game:GetService(“TweenService”)

local function moveItem(item, wp)

TweenModule.TweenModulePosition(PrimaryPart,TweenInfo.new(1.5,Enum.EasingStyle.Linear),{Position = wp.Position})

wait(1.5)

end

script.Parent.MainPart.SFX:Play()

moveItem(PrimaryPart, d1)

local cframe= CFrame.new(PrimaryPart.PrimaryPart.Position) – Current CFrame

PrimaryPart:SetPrimaryPartCFrame(cframe * CFrame.Angles(0, math.rad(-90), 0))

wait()

moveItem(PrimaryPart, d2)

local cframe= CFrame.new(PrimaryPart.PrimaryPart.Position)

PrimaryPart:SetPrimaryPartCFrame(cframe * CFrame.Angles(0, math.rad(0), 0))

wait()

moveItem(PrimaryPart, d3)

local cframe= CFrame.new(PrimaryPart.PrimaryPart.Position)

PrimaryPart:SetPrimaryPartCFrame(cframe * CFrame.Angles(0, math.rad(90), 0))

moveItem(PrimaryPart, d4)

local cframe= CFrame.new(PrimaryPart.PrimaryPart.Position)

PrimaryPart:SetPrimaryPartCFrame(cframe * CFrame.Angles(0, math.rad(0), 0))

moveItem(PrimaryPart, d5)

local boom = Instance.new(“Explosion”)

boom.Parent = script.Parent

boom.Position = script.Parent.MainPart.Position

boom.BlastRadius = 20

script.Parent.MainPart.BoomSFX:Play()

wait(2)

script.Parent:Destroy()

–end)

I should also add that I am using a external module to help with model tweening.

You should do all this with a Model that has 1 primary part that is anchored the rest should be unachored but welded to that part

then tween that primarypart to a part/node just like the part you are tweening. also the part/node needs to be rotated to the direction you want the model to face

you can even make it go the same speed through the tweens by using distance to next node by magnitude and dividing a movement speed to this

Try something like this with the settings I explained above it alot simpler than what you are trying to setup there

local PrimaryPart = workspace.TestModel.PrimaryPart
local Speed = 5

for i , node in ipairs(workspace.Nodes:GetChildren()) do
	local TimeToNode = (PrimaryPart.Position - node.Position).Magnitude
	local tween = game:GetService("TweenService"):Create(PrimaryPart, TweenInfo.new(TimeToNode/Speed,Enum.EasingStyle.Linear) , {CFrame = node.CFrame})
	tween:Play()
	tween.Completed:wait()
end
2 Likes

https://gyazo.com/d16a79d22903f4828f9df6998571799a Thank you! It not only fixed the problem but allowed me to add smooth turning and make it look much better

1 Like