Trailer system problems

  1. What do I want to achieve?
    I need to create a system where you move trailers with your mouse when clicked on

  2. What is the issue?
    I have a part that I can move around with my mouse when clicked on but when I weld it to the trailer or the other solutions I have tried I does not work
    not on trailer
    Untitled Game - Roblox Studio (gyazo.com)

on trailer
Untitled Game - Roblox Studio (gyazo.com)

  1. What solutions have I tried so far?
    I have tried welding, ropes etc

here is the code to move the part (it is located in startergui as a localscript)

local player = game.Players.LocalPlayer
local mouse = player:GetMouse()
local part = workspace.Parta

local tracking = nil -- will be the part your moving
mouse.Button1Down:Connect(function()
	if tracking then 
		tracking = nil
		return
	end
	local hit = mouse.Target
	if hit == part then
		tracking = hit
	end
end)

mouse.Move:Connect(function()
	if tracking then
		local hit = mouse.Hit.Position * Vector3.new(1,0,1)
		local up = Vector3.new(0,tracking.Size.Y/2,0)
		game.TweenService:Create(tracking, TweenInfo.new(0.3,Enum.EasingStyle.Quad,Enum.EasingDirection.Out,0,false,0),
			{CFrame = CFrame.new(hit + up)}):Play()
	end
end)

Have you tried adding any print outputs to the mouse.Move connection while the part is attached to see if it’s firing, or getting past tracking?

1 Like

The problem is not in the movement of your part, but in the weld that was inserted in it, if you want to move your part again, you must destroy the weld of the part.

Click here to see a little more about weld properties

To correct your system, we just need to identify any types of welds present on the part we want to move and thus destroy them.

--// Services
local Players = game:GetService('Players')
local TweenService = game:GetService('TweenService')

--// Workspace
local Part = workspace:WaitForChild('Parta')

--// Players
local LocalPlayer = Players.LocalPlayer

--// LocalPlayer
local Mouse = LocalPlayer:GetMouse()

--// Variables
local Tracking

--// Functions
function OnMove()
    if Tracking then
        local up = Vector.yAxis * Tracking.Size.Y / 2
        local hit = Mouse.Hit.Position * Vector3.new(1, 0, 1)

        TweenService:Create(Tracking, TweenInfo.new(.3, Enum.EasingStyle.Quad, Enum.EasingDirection.Out), {
            CFrame = CFrame.new(hit + up)
        }):Play()
    end
end

function OnButton1Down()
    if Tracking then
        Tracking = nil
        return
    end

    local hit = mouse.Target
    if hit == part then
        for _, weld in next, hit:GetChildren() do
            if not weld:IsA('Weld') or not weld:IsA('WeldConstraint') then continue end
            weld:Destroy()
        end

        Tracking = hit
    end
end

--// Connections
Mouse.Move:Connect(OnMove)
Mouse.Button1Down:Connect(OnButton1Down)

There is the case that the weld is not on the part in question, so you will have to find out where the solder is and remove it in order to be able to move the part.