#Complex problem with scaling/editing feature
1 messages · Page 1 of 1 (latest)
local function scale(adornee: BasePart, handle: Frame, currentSizeX, currentSizeY)
local part = adornee.Parent.Part
local maxSizeX = adornee.Size.X
local maxSizeY = adornee.Size.Y
if handle.Name == "Top" then
local newScale = handle.Position.Y.Offset / handle.Parent.AbsoluteSize.Y
part.Size = Vector3.new(currentSizeX,math.clamp(maxSizeY * (1 - newScale), 0.1, maxSizeY),0.5)
part.CFrame = adornee.CFrame * CFrame.new(0,-(maxSizeY / 2) + part.Size.Y / 2,0)
elseif handle.Name == "Bottom" then
local newScale = handle.Position.Y.Offset / handle.Parent.AbsoluteSize.Y
part.Size = Vector3.new(currentSizeX,math.clamp(maxSizeY * (newScale), 0.1, maxSizeY),0.5)
part.CFrame = adornee.CFrame * CFrame.new(0,(maxSizeY / 2) - part.Size.Y / 2,0)
elseif handle.Name == "Left" then
local newScale = handle.Position.X.Offset / handle.Parent.AbsoluteSize.X
part.Size = Vector3.new(math.clamp(maxSizeX * (1 - newScale), 0.1, maxSizeX),currentSizeY,0.5)
part.CFrame = adornee.CFrame * CFrame.new((maxSizeX / 2) - part.Size.X / 2,0,0)
elseif handle.Name == "Right" then
local newScale = handle.Position.X.Offset / handle.Parent.AbsoluteSize.X
part.Size = Vector3.new(math.clamp(maxSizeX * (newScale), 0.1, maxSizeX),currentSizeY,0.5)
part.CFrame = adornee.CFrame * CFrame.new(-(maxSizeX / 2) + part.Size.X / 2,0,0)
end
end
adornee is the hitbox (original shape)
Part is the actual part I'm trying to change
still stuck on this problem to this day
** You are now Level 1! **
probably because you're passing in the wrong size local function scale(adornee: BasePart, handle: Frame, currentSizeX, currentSizeY) - value of currentSizeX and currentSizeY? can't you get that from the parts existing size?
maybe related to your startDrag function?
you've only shown one part of it and the problem probably isnt even in there