Okay, so i’m trying to make a grid for a building tool. I’m new at coding, and I can’t find a way to apply the actual grid. I tried a lot of things, like making the location from local script be grid-iffied first, but that didn’t work either. Not sure what to do.
ServerScript:
local tool = script.Parent
local clickEvent = game.ReplicatedStorage:WaitForChild('BlockPlace')
local clickEventConnection
-- Partval = tool.PartNum.Value
function griddify(locationy)
return math.floor(locationy / 5) * 5
end
local function createPart(location, griddify)
local part=tool.Part0:Clone()
part.CanCollide=true
part.Transparency = 0
part.CFrame = (griddify(location))
script.Parent.Click:Play()
part.Parent = workspace
part.Anchored=true
part.Orientation=Vector3.new(0,0,0)
end
function onClick(player, clickLocation)
createPart(clickLocation)
end
local function onEquip()
clickEventConnection = clickEvent.OnServerEvent:connect(onClick)
end
local function onUnequip()
clickEventConnection:disconnect()
end
tool.Equipped:connect(onEquip)
tool.Unequipped:connect(onUnequip)
LocalScript:
local tool = script.Parent
local player = game.Players.LocalPlayer
local mouse = player:GetMouse()
local clickEvent = game.ReplicatedStorage:WaitForChild('BlockPlace')
--round(mouse.Hit.Position,3)
local function onActivate()
local clickLocation = mouse.Hit
clickEvent:FireServer(clickLocation)
end
tool.Activated:connect(onActivate)