You need to know basis of scripting or you’ll not understand this tutorial
Also its simple, so listen carefully, here is how it works:
Step 1
Basically, you need to know what is position of block,
Example: If you have this blue square, the center of it, from all sides is the position, like if left of of the block is (5,1,5), center is (5.5,1,5) then block position will be the centre of it position
Step 2
Raycasting
If you don’t know what this is then learn it from here, or you cannot understand next steps
Step 3
I will tell how it works, so you can understand and make a better one
Grid part: block under the block your placing
This will create a grid, blocks stick to each other, with an image/surface gui frame on top, so when your using your building system, raycast downwards the block, so you will know what block/grid is under it, that will be your grid part, when your placing a block, the grid part position will be the position
Once again watch the video I kept at starting, when your placing a block, the grid part position will be the part your placing’s position, so you cannot place in between those grid parts
Step 4: How to make grid block
1.Make a part which will be the size of your grid
2.Make it look like a grid part, here is how I did it
3.Now add a local script in your building system script
-
Read this below to understand the script
Now we will make a grid in all x boxes, top to down, and z boxes, left to right
Means for every left to right block you need to make a top to down, this cannot be understood if you read it without thinking, try to think how to clone this grid into x and z axis -
Don’t copy paste this script below, read it
local gridpart = game.ReplicatedStorage:FindFirstChild("GridPart")
for x = 5,55,5 do
for z = 5,55,5 do
task.wait(0.05) -- to create a tween effect
local gridclone = gridpart:Clone() -- clones and keeps in workspace
gridclone.Parent = workspace
gridpart.Position = Vector3.new(x,0.5,z)
gridpart.Anchored = true
gridpart.CanCollide = false
end
end
Now, you might be like
Don’t worry its quite simple, 10 line script, try to understand it
Step 5, test it
Now your happy that you made a working grid system
Tutorial is done, but below is a tutorial on how to make a simple building system as in video
Step 1
local selectionpart = Instance.new("Part",workspace)
selectionpart.Size = Vector3.new(5,5,5)
selectionpart.Transparency = 0.5
selectionpart.CanCollide = false
selectionpart.Anchored = true
local player = game.Players.LocalPlayer
local mouse = player:GetMouse()
mouse.Move:Connect(function()
local raycastresult = workspace:Raycast(mouse.Hit.Position + Vector3.new(0,150,0),Vector3.new(0,-250,0))
if raycastresult ~= nil then -- if there is nothing under the selection part
if raycastresult.Instance.Name == "GridPart" then -- checks if its a grid part
selectionpart.Position = raycastresult.Instance.Position + Vector3.new(0,selectionpart.Size.Y/2,0)
end
end
end)
Here is how it works:
Sorry for the lag video, my pc is not a high-end pc, but you can see it work in this video
Also this is not a tutorial for making a building system, so I’m not showing it here.