Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

changing the increment for a custom resize tool?

I am having trouble changing the increment for a resize tool I adapted for my project.

local tool = script.Parent
local plr = game.Players.LocalPlayer
local mouse = plr:GetMouse()
enabled = true
local selectionBox
local selectionLasso
local handles
local previousDistance
local originalpart
local buttonupconnection
local tempart

function onHandlesDown(normal)
	previousDistance = 0
end



function onHandlesDrag(normal, distance)
	if handles.Adornee then
		local delta = distance - previousDistance
		if math.abs(delta) >= handles.Adornee.ResizeIncrement then
			local sizeDelta = math.floor(delta / handles.Adornee.ResizeIncrement + 0.5) * handles.Adornee.ResizeIncrement
			if handles.Adornee:Resize(normal, sizeDelta) then
				previousDistance = distance
				--send changes to server
				buttonupconnection = mouse.Button1Up:connect(function()onButton1Up(mouse,handles.Adornee)end)
	--
			end
		end
	end
end




function onButton1Up(mouse,part)
	if part and script.Parent.Parent == plr.Character then
	local size = part.Size
	local cfr = part.CFrame
	script.Parent.PartChange:FireServer(originalpart,size,cfr)
	end
end




function onButton1Down(mouse)
	local findpart = game.ReplicatedStorage.BuildingParts:FindFirstChild(mouse.Target.Name)
	if tempart then
		tempart:Destroy()
		end
	if mouse.Target == nil or mouse.Target.Locked or not findpart then
		print("nil")
		selectionBox.Adornee = nil
		selectionLasso.Part = nil
		handles.Adornee = nil
	else
		print("not nil")
		originalpart = mouse.Target
		tempart = findpart:Clone()
		tempart.CanCollide = false
		tempart.Anchored = true
		tempart.Transparency = 0.6
		tempart.Size = originalpart.Size
		tempart.Parent = game.Workspace
		tempart.CFrame = originalpart.CFrame
		tempart.BrickColor = BrickColor.new("Lime green")
		selectionBox.Adornee = tempart
		selectionLasso.Part = tempart
		handles.Adornee = tempart
		handles.Faces = tempart.ResizeableFaces
	end
end




function onEquippedLocal(mouse)
	mouse.Button1Down:connect(function() onButton1Down(mouse) end)

	local character = script.Parent.Parent
	local player = game.Players:GetPlayerFromCharacter(character)
	
	selectionBox = Instance.new("SelectionBox")
	selectionBox.Color = BrickColor.Blue()
	selectionBox.Adornee = nil
	selectionBox.Parent = player.PlayerGui

	selectionLasso = Instance.new("SelectionPartLasso")
	selectionLasso.Name = "Model Delete Lasso"
	selectionLasso.Humanoid = character.Humanoid
	selectionLasso.Parent = game.workspace
	selectionLasso.Part = nil
	selectionLasso.Visible = true
	selectionLasso.archivable = false
	selectionLasso.Color = BrickColor.Red()

	handles = Instance.new("Handles")
	handles.Color = BrickColor.Blue()
	handles.Adornee = nil
	handles.MouseDrag:connect(onHandlesDrag)
	handles.MouseButton1Down:connect(onHandlesDown)
	handles.Parent = player.PlayerGui
end

function onUnequippedLocal()
	selectionBox:Destroy()
	selectionLasso:Destroy()
	handles:Destroy()
	if handles.Adornee then
		handles.Adornee:Destroy()
	end
	if buttonupconnection then
	buttonupconnection:Disconnect()
	end
end


tool.Equipped:connect(onEquippedLocal)
tool.Unequipped:connect(onUnequippedLocal)

the current function that I am concerned about is onhandlesdrag. I tried changing various things such as handles.adornee.sizeincrement. I tried changing sizedelta up but that didnt work.

I want to change the increment to 0.5, but any attempts that didn't end in failure only ended in the part resizing 1 stud.

1 answer

✓ Accepted answer

Sadly, ResizeIncrement is a read-only value that is the minimum size :Resize() can do. You're going to have to look into editing the size property, you might be able to find a module that is :Resize() but just unlocked?

This discussion is preserved as it was. New answers, comments, and votes are closed.