Creating building system similar to build a boat and plane crazy

Hey! i want to create a building system like build a boat and plane crazy i need help with it here’s a test code i write.

the blocks dont really work, when i use facing front and left are making the block go inside them and also when i try making grid it mostly makes them go away from cursor and wont work properly!

local Block = Instance.new("Part")
Block.Anchored = true
Block.Parent = game.Workspace
Block.Size = Vector3.new(1,1,1)
local Mouse = game.Players.LocalPlayer:GetMouse()
Mouse.TargetFilter = Block
Mouse.Move:Connect(function()
	local MousePos = game.Workspace.CurrentCamera:ScreenPointToRay(Mouse.X,Mouse.Y)
	local raycastparams = RaycastParams.new()
	raycastparams.FilterDescendantsInstances = {Block}
	local raycast = game.Workspace:Raycast(MousePos.Origin,MousePos.Direction * 100,raycastparams)
	if raycast then
	Block.Position = Vector3.new(
		math.floor(raycast.Position.X) + raycast.Normal.X + Block.Size.X / 2,
		math.floor(raycast.Position.Y) + raycast.Normal.X + Block.Size.Y / 2,
		math.floor(raycast.Position.Z) + raycast.Normal.X + Block.Size.Z / 2
	)
	print(raycast.Material,raycast.Distance,raycast.Normal)
	end
end)
1 Like

Im not sure if I can help you with the grid as I haven’t done it before, but I can help you get the thing following the mouse
You wanna use Mouse.UnitRay instead of CurrentCamera:ScreenPointToRay because it works better with the mouse
You also forgot to exclude the block for the raycast params
You can set the block position directly to the raycast pos with that size offset

Block.Position = raycast.Position + Vector3.new(0,Block.Size.Y/2,0)

You could also change it RenderStepped instead of Mouse.Move()