-
I am trying to Apply a script to a model so the entire model moves
-
I can only get the primary part to move and not the entire model
-
I tried referencing the primary part but the model doesnt move. When I put the script into the primary part only that part moves. I have tried i,v but I don’t think I understand it well enough to fit it into what I have already written
Here is my total model with part names inside:
Moving Tractor
Cube1
Cube2
Cube3
Cube4
here is the code I started with that works on a model that only has one part.
local TweenService = game:GetService(“TweenService”)
local RunService = game:GetService(“RunService”)
local MovingTractor = script.Parent.PrimaryPart
local TweenInfo = TweenInfo.new(7, Enum.EasingStyle.Cubic, Enum.EasingDirection.InOut, -1, true)
local Tween = TweenService:Create(MovingTractor, TweenInfo, {
CFrame = MovingTractor.CFrame * CFrame.new(0, 0, -40)
})
Tween:Play()
local lastPosition = MovingTractor.Position
RunService.Stepped:Connect(function(_, deltaTime)
local currentPosition = MovingTractor.Position
local deltaPosition = currentPosition - lastPosition
local velocity = deltaPosition / deltaTime
MovingTractor.AssemblyLinearVelocity = velocity
lastPosition = currentPosition
end)