https://i.gyazo.com/1201cdcf8986de2068c8caca32935550.mp4
The part should be moving locally not globally how should I fix this
Don’t mind the spaghetti code its just a concept
function BuildMove()
DeselectHandles()
first = true
mode = 2
local origin
if selected then
if selected:IsA('Model') then origin = selected:GetPrimaryPartCFrame() else origin = selected.CFrame end
end
mouse.Button1Up:Connect(function()
if selected then
if selected:IsA('Model') then origin = selected:GetPrimaryPartCFrame() else origin = selected.CFrame end
end
end)
script.Parent.Handles.MouseDrag:Connect(function(a, b)
if selected and selected.Name == 'Block' and origin then
local CF
if selected:IsA('Model') then
CF = selected:GetPrimaryPartCFrame()
selected:SetPrimaryPartCFrame(origin + Vector3.FromNormalId(a) * (math.floor(b / 1)))
else
CF = selected.CFrame
selected.CFrame = origin + Vector3.FromNormalId(a) * (math.floor(b / 1))
end
else
if selected then
DeselectHandles()
selected = nil
end
end
end)
repeat
wait()
if selected and selected.Name == 'Block' then
if selected:IsA('Model') then
script.Parent.Handles.Adornee = selected.PrimaryPart
script.Parent.SelectionBox.Adornee = selected.PrimaryPart
else
script.Parent.Handles.Adornee = selected
script.Parent.SelectionBox.Adornee = selected
end
else
if selected then
DeselectHandles()
selected = nil
end
end
until mode ~= 2
if mode ~= 2 then
DeselectHandles()
end
end