so, i am making a building game. and i am getting trouble with making a grid system
i completely don,t know how to make a one
i tried to seek tutorials in forums and youtube videos, but it seems so complicated
they all uses roblox math (something that i have no clue to use), and is needed to group parts as model (wich will take a ertenety, since its a lot of parts)
there is my script part that needs the grid:
local EventsFolder = script.Parent.Parent.Events.BuildingEvents
local BlockChoosen = EventsFolder.BlockChoosen
local PlaceBlock = EventsFolder.PlaceBlock
local Tool = EventsFolder.Parent.Parent
local Grid = 4
local BlockPOS = Vector3.new(0,0,0)
local BlockROT = Vector3.new(0,0,0)
local Block = nil
local BlockG
local SelectionBox = Tool.SelectionBox
BlockChoosen.Event:Connect(function(BlockChosen, BlockGroup)
BlockG = BlockGroup
Block = BlockChosen:Clone()
SelectionBox.Adornee = Block
Block.Parent = workspace.BlockPreviewArea
if Block then
Block.CFrame = CFrame.new(Vector3.new(BlockPOS.X, BlockPOS.Y, BlockPOS.Z))
Block.CanCollide = false
Block.Anchored = true
end
-- Block.Transparency = 0.5
end)
game.Players.LocalPlayer.CharacterAdded:Wait()
local Char = game.Players.LocalPlayer.Character:WaitForChild("HumanoidRootPart")
local BlockMagnitude
local MaxMagnitude = 200
game.Players.LocalPlayer:GetMouse().Move:Connect(function()
local MousesUnitRay = game.Players.LocalPlayer:GetMouse().UnitRay
local ray = Ray.new(MousesUnitRay.Origin, MousesUnitRay.Direction * 100000)
local i, POS = workspace:FindPartOnRayWithIgnoreList(ray, {Block, Char}, true)
BlockPOS = game.Players.LocalPlayer:GetMouse().Hit.p
if Block then
if Block:IsA("Part") then
BlockMagnitude = (Block.Position - Char.Position).Magnitude
Block.CFrame = CFrame.new(Vector3.new(BlockPOS.X, BlockPOS.Y, BlockPOS.Z))
elseif Block:IsA("Model") then
BlockMagnitude = (Block.Position - Char.Position).Magnitude
Block:PivotTo(CFrame.new(Vector3.new(BlockPOS.X, BlockPOS.Y, BlockPOS.Z)))
end
game.Players.LocalPlayer:GetMouse().TargetFilter = Block
if BlockMagnitude <= MaxMagnitude then
SelectionBox.Color3 = Color3.fromRGB(13, 105, 172)
SelectionBox.SurfaceColor3 = Color3.fromRGB(13, 105, 172)
else
SelectionBox.Color3 = Color3.fromRGB(172, 0, 3)
SelectionBox.SurfaceColor3 = Color3.fromRGB(172, 0, 3)
end
end
end)
can someone help me with this situation? (making it simpler and clear)