What do i want: i want the moving part to push the “car” that I’m inside of or any other part, even tho the other parts aren’t anchored it just phases threw them I’m not sure why its doing that
here is the code for the “pusher”
– Roblox Script: Pusher using simple loop
local Workspace = game:GetService(“Workspace”)
local Model = Workspace:FindFirstChild(“Push”) – Replace “ModelName” with the name of your model
if not Model then
warn(“Model not found in Workspace. Make sure the model exists and its name is correct.”)
return
end
local pushDistance = 10 – Change this value to set the distance the model moves
local pushDuration = 4 – Change this value to set the duration of the push movement (in seconds)
local pullDuration = 2 – Change this value to set the duration of the pull movement (in seconds)
local function moveModel(model, distance, duration)
local initialPositions = {}
for _, part in ipairs(model:GetDescendants()) do
if part:IsA(“BasePart”) then
initialPositions[part] = part.Position
local newPosition = part.Position + Vector3.new(0, 0, distance) – Change the axis (X, Y, or Z) if you want to move the model in a different direction
local tweenInfo = TweenInfo.new(duration, Enum.EasingStyle.Sine, Enum.EasingDirection.Out)
local tween = game:GetService(“TweenService”):Create(part, tweenInfo, {Position = newPosition})
tween:Play()
end
end
return initialPositions
end
local function restoreModel(model, initialPositions, duration)
for _, part in ipairs(model:GetDescendants()) do
if part:IsA(“BasePart”) and initialPositions[part] then
local tweenInfo = TweenInfo.new(duration, Enum.EasingStyle.Sine, Enum.EasingDirection.In)
local tween = game:GetService(“TweenService”):Create(part, tweenInfo, {Position = initialPositions[part]})
tween:Play()
end
end
end
while true do
local initialPositions = moveModel(Model, pushDistance, pushDuration)
wait(pushDuration)
restoreModel(Model, initialPositions, pullDuration)
wait(pullDuration)
wait(4)
end