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)