I need help on the grid part of my placement system. I'm not sure how to place the block with the grid. I tried finding numerous videos on the internet and I cant find a solution. I am trying to make a placement system like in the game "Skywars". Thank you, any help will be appreciated.
Local Script:
local player = game.Players.LocalPlayer
local mouse = game.Players.LocalPlayer:GetMouse()
local off = false
script.Parent.Equipped:Connect(function()
local clonedbrick = game.ReplicatedStorage.Brick:Clone()
if mouse ~= nil then
mouse.TargetFilter = clonedbrick
clonedbrick.Transparency = .5
clonedbrick.Parent = workspace
while mouse ~= nil do
clonedbrick.Position = mouse.Hit.p + Vector3.new(0,2,0)
wait()
if off then
clonedbrick:Destroy()
off = false
break
end
end
end
end)
script.Parent.Activated:Connect(function()
local BrickToPlace = game.ReplicatedStorage.Brick:Clone()
local pos = mouse.Hit.p + Vector3.new(0,2,0)
if(pos - player.Character.HumanoidRootPart.Position).magnitude <= 12 then
script.Parent.RemoteEvent:FireServer(pos)
end
end)
script.Parent.Unequipped:Connect(function()
off = true
end)
Server script
script.Parent.RemoteEvent.OnServerEvent:Connect(function(plr,pos)
local BlocksFolder = game.Workspace.Blocks -- don't worry about this.
local BrickToPlace = game.ReplicatedStorage.Brick:Clone()
BrickToPlace.Parent = BlocksFolder
BrickToPlace.CanCollide = true
BrickToPlace.Position = pos
BrickToPlace.Name = plr.Name
end)
