You can try on mouse drag to check for the delta distance and then scale it
if handles.Adornee then -- the part you want to scale exists
local delta = distance - previousDistance
if math.abs(delta) >= 1 then -- if it's over 1 stud
local resizeDelta -- how much you want to scale
if delta > 0 then -- it's positive
resizeDelta = 4
elseif delta < 0 then -- it's negative
resizeDelta = -4
end
if handles.Adornee:Resize(side, resizeDelta) then
previousDistance = distance -- resets the distance
end
end
end
NOTE: DO NOT USE THIS IN YOUR GAME as it is 100% going to fail on serverside conversion. This tool was made somewhere around 2009 to 2012 and was designed with filtering disabled in mind which means it is client sided. So you should only use this tool for learning how it works.
You cast a ray in the direction of the mouse from the camera, and another ray from the part you want to scale in the direction you want to scale it eg: From the part to Enum.NormalID.Top
If you check for the closest points on the 2 rays you can determine how much the mouse traveled:
local handleDirection = (part.Position - handle.Position).Unit
local cameraPosition = workspace.CurrentCamera.CFrame.Position
local mouseDirection = (cameraPosition - mouse.Hit.Position).Unit
local a = handleDirection:Dot(handleDirection)
local b = handleDirection:Dot(mouseDirection)
local e = mouseDirection:Dot(mouseDirection)
local d = a*e - b*b
local mousePosition
if d ~= 0 then
local r = part.Position - cameraPosition
local c = handleDirection:Dot(r)
local f = mouseDirection:Dot(r)
local s = ( b * f - c * e ) / d
local t = (a * f - c * b ) / d
mousePosition = part.Position + handleDirection * s
end
local distance = (mousePosition - handle.CFrame.Position).Magnitude