I’m trying to tween a model so I would have to tween the primary part, i am tweening the primary part with weldconstraints and all it is tweening is the primary part.
Tween part
local function tweenToPosition(part)
if model then
local primaryPart = model.PrimaryPart
local goal = {}
goal.CFrame = CFrame.new(part.Position)
local tweenInfo = TweenInfo.new(
0.5,
Enum.EasingStyle.Quad,
Enum.EasingDirection.Out,
0,
false,
0
)
local tween = TweenService:Create(primaryPart, tweenInfo, goal)
tween:Play()
end
end
local function onInput(input, gameProcessedEvent)
if input.UserInputType == Enum.UserInputType.MouseMovement then
local hit = game:GetService("Players").LocalPlayer:GetMouse().Target
if model then
if hit and hit:IsDescendantOf(model) then
if not highlight then
highlight = game.ReplicatedStorage.MergingSystemMain.Highlight:Clone()
highlight.Parent = model
end
else
if highlight then
highlight:Destroy()
highlight = nil
end
end
if isDragging then
local mousePosition = input.Position
local ray = camera:ScreenPointToRay(mousePosition.X, mousePosition.Y)
local worldPosition = ray.Origin + ray.Direction * ((-0.9 * ray.Origin.Y) / ray.Direction.Y)
local groundHeight = 0
local groundRay = Ray.new(worldPosition, Vector3.new(0, -1, 0) * 1000)
local groundPart, groundPos = workspace:FindPartOnRayWithIgnoreList(groundRay, {model})
if groundPart then
groundHeight = groundPos.Y
end
if worldPosition.Y < groundHeight + model.PrimaryPart.Size.Y / 2 then
worldPosition = Vector3.new(worldPosition.X, groundHeight + model.PrimaryPart.Size.Y / 2, worldPosition.Z)
end
model:SetPrimaryPartCFrame(CFrame.new(worldPosition))
end
end
end
end
local function onInputEnded(input, gameProcessedEvent)
if input.UserInputType == Enum.UserInputType.MouseButton1 then
isDragging = false
if model then
for _, part in pairs(model:GetDescendants()) do
if part:IsA("BasePart") then
part.CanCollide = true
end
end
local closestPart = nil
local closestDist = math.huge
for _, part in pairs(boatSpotsFolder:GetChildren()) do
if part:IsA("BasePart") and part.CanCollide then
if model then
local dist = (model.PrimaryPart.Position - part.Position).Magnitude
if dist < closestDist then
closestPart = part
closestDist = dist
end
end
end
end
if closestPart then
tweenToPosition(closestPart)
end
end
end
end