Increase size of parts via dragging in game

There is tutorial for this, you can find some help here.

That’s got nothing to do with what I’m after

To get the exact functionality of that video you can follow my approach but simply snap DistX and DistZ to your grid by modulo.

Wait, the code you supplied works? :open_mouth:

Well the system is same? - placement system - you can customize it to your use…

No it’s not tho. His system is how to place items, I already have that coded in. I’m after how to code the exact floor system as mentioned in my OP

Actually, the system is pretty much the same. It’s a placement system. I’m actually using mine as a selection box. Though I quickly realized a 2D one is better UX. Can’t be bothered to fix it. For that placement of the floor in the video, if you snap the drag to a grid, it constrains it to tiles. I mean you could also probably make it simpler by constraining it to a simple distance instead of splitting up both the X, and the Z. Since doing that allows for free manipulation on both axis. And since it’s a floor, you should be able to set your own Y. These are all size values btw, not position.

I was actually thinking it was another system as well. But once I started thinking of it as a placement system it became easier to manipulate. There are some bugs in my code though. You should really math.abs(DistX) and math.abs(DistZ) if you will be going that route. Otherwise if you use a single distance for the size. (Essentially making a square) the value should always be positive.

RunService:BindToRenderStep("DrawPart", Enum.RenderPriority.Input.Value, function(Step) 
	local Hit = Mouse.Hit
	local Distance = 0
	if LastHit then Distance = (LastHit.Position - Hit.Position).Magnitude end
	local Center = (LastHit.Position + Hit.Position) / 2
	local DistX = math.abs(LastHit.Position.X - Hit.Position.X) -- Allows free manipulation on PartSize X based on distance
	local DistZ = math.abs(LastHit.Position.Z - Hit.Position.Z) -- Allows free manipulation on PartSize.Z

       	
	
	Workspace.BoxSelect.CFrame = CFrame.new(Center)
	Workspace.BoxSelect.Size = Vector3.new( DistX, 2, DistZ )
       -- Uncomment the line below for tiles.
        -- Workspace.BoxSelect.Size = Vector3.new( Distance, 2, Distance ) 
end)

DistX and DistZ uses the difference between the two points in order to find the size. Because of that math.abs is neccessary to handle non-positive vectors.

3 Likes

I was referring to the fact that I already have placement down, my question was aimed at how to make draggable floor be resized. Not how to place the floor.

I will have to check out your code sometime in the future :+1:

1 Like