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)