Creating a floor placement system similar to Cruise Ship Tycoon

Hi there, I would like to know how to create a floor placement system similar to cruise ship tycoon 2, where you click and drag to place it.

When the player clicks, store the starting position, and when he stops, store the ending position, clamp them to the grid, then create a loop that goes from Position1.X to Position2.X with a step of grid (your grid) and a nested loop (inside the one I just talked about) from Position1.Z to Position2.Z then build the blocks there.

local GRID = 2 

local startX = math.min(position1.X, position2.X)
local endX = math.max(position1.X, position2.X)

local startZ = math.min(position1.Z, position2.Z)
local endZ = math.max(position1.Z, position2.Z)

--? We get min and max since Roblox won't loop if the first parameter is
--? smaller than the second and the step is positive

for i = startX, endX, GRID do
	for v = startX, endX, GRID do
		local part = partToBePlace:Clone()
		part.Position = Vector3.new(startX + GRID * i, y, startZ + GRID * v)
		paret.Parent = workspace
	end
end

I assume you already have a placement system and it’s already locked to the part, this is just for the click and drag part.

4 Likes

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.