So I tried making a placement grid but i don’t have many experience with roblox coding so i figured out something on my own instead of youtube videos etc bc its too complicated for me yet. I created this code which works but not very well. The issue here is that when i place a block on some surface, it places it inside the block but this doesnt happen all the time (block on block worked for some sides and when i built another structure it worked in the opposite directions but didnt on the same ones) so i dont really know what is going on.
Sorry for my explanation, im not good at explaining things and thanks for your time.
Here is the local script( server script just places the block so its not really needed to put here ):
local mouse = game:GetService("Players").LocalPlayer:GetMouse()
local RS = game:GetService("ReplicatedStorage")
local UIS = game:GetService("UserInputService")
local preview
local block
UIS.InputBegan:Connect(function(input)
if input.KeyCode == Enum.KeyCode.R then
if preview == nil then
block = RS:WaitForChild("Block")
preview = block:Clone()
preview.Transparency = 0.5
preview.CanCollide = false
preview.CanQuery = false
preview.CastShadow = false
preview.Parent = game:GetService("Workspace")
else
preview:Destroy()
preview = nil
end
end
if input.UserInputType == Enum.UserInputType.MouseButton1 and mouse.Target and preview then
RS:WaitForChild("RemoteFunction"):InvokeServer(block, preview.Position)
end
end)
spawn(function()
while wait() do
if preview then
-- this is the part of code that causes the issues, most likely..
preview.Position = Vector3.new(math.round(mouse.Hit.X/preview.Size.X)*preview.Size.X,math.round(mouse.Hit.Y/preview.Size.Y)*preview.Size.Y,math.round(mouse.Hit.Z/preview.Size.Z)*preview.Size.Z)
----------------------------------------------------------------
end
end
end)
Edit:
I just realised that the placement depends on the 6 coordinates, whenever they are positive or negative. So basically if the y coordinate is higher than 0 it will place blocks up and if it is lower then 0 it will place blocks down…
Any idea how to fix this without some complicated stuff