Moving Part Tool Help!

Hello, I am trying to make a part resize script but for some reason its not working on parts inside models but works perfectly fine on normal parts in the workspace! This is a localscript inside a tool that adjusts the parts size. I am trying to get it to only move a part called “placeholder” inside a model.

image

local Tool = script.Parent

enabled = true

local selectionBox
local handles

local previousDistance

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 + 2) * handles.Adornee.ResizeIncrement
			if handles.Adornee:Resize(normal, sizeDelta) then
				previousDistance = distance
			print(distance)	
			end
		end
	end
end

function onButton1Down(mouse)
	if mouse.Target == nil or mouse.Target.Locked then
			
		
		selectionBox.Adornee = nil
		handles.Adornee = nil
	else
	if mouse.Target.Parent:FindFirstChild("placeholder") or mouse.Target.Name == "placeholder" then
			local block = mouse.Target.Parent.placeholder
		
		handles.Adornee = block --block:Clone()

		--	print(handles.Adornee.Parent)
		selectionBox.Adornee = handles.Adornee

		handles.Faces = handles.Adornee.ResizeableFaces
	end
	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

	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:Remove()
	handles:Remove()
	if handles.Adornee == nil then
		else
		game.ReplicatedStorage.ServerSide:FireServer(handles.Adornee,handles.Adornee.Size)

end	
end


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

Thanks for the help!

1 Like

So have you added prints into the code to show the logic flows as you expect?
Instead of attempting resize can you change its colour?

2 Likes

I have, I can change the color of the block, I have put in prints, I honestly just have 0 idea what’s going on? I just changed it so you could resize any block and it still does not work on the model. Heres a video: robloxapp-20210528-0751097.wmv (1.1 MB)

1 Like

Welp, I just figured it out… I just needed to change the collidabilty of the current part to false and then turn it back on again when the tool is put away…

1 Like

Ok, so in the video it looks like you are not grabbing the item.
Have you confirmed that the selection has actually occurred?
Also in Studio in Client and Server you can select and modify an object whilst the code is running so can you select the part on the model and see that it is selected and change its size manually?

1 Like