Need help with my terrible placement system

Here is my terrible placement code:

local BlocksFolder = game.Workspace.Blocks

local BlockPrev = game.Workspace["Blocks Preview"]

local plr = game:GetService("Players").LocalPlayer

local mouse = plr:GetMouse()

script.Parent.Equipped:Connect(function()
	local target = game.Workspace.Baseplate
	mouse.TargetFilter = BlockPrev.BlockPreview
	while true do
		task.wait()
		BlockPrev.BlockPreview.Position = Vector3.new(mouse.Hit.X,1.5, mouse.Hit.Z)
	end

end)

script.Parent.Unequipped:Connect(function()

	BlockPrev.BlockPreview.Position = Vector3.new(5, 1.5, -10)

end)

script.Parent.Activated:Connect(function()
	local glass = game.Workspace.Blocks.Glass_Block:Clone()
	glass.Parent = game.Workspace
	glass.Position = BlockPrev.BlockPreview.Position
end)

I need help with making it better because i do not know how to make one and this is my first try.

If help is given please leave this part of the code in it:

local BlocksFolder = game.Workspace.Blocks

local BlockPrev = game.Workspace["Blocks Preview"]

Try using the search tool up top. There have been quite a few posts about placement systems. Try using “block building” or “sandbox” as the search term too.

1 Like