Hello, I am @kaykay101wally and am looking how to solve my problem. I have already created a system that creates a placeholder part that appears at the mouse cursor (using a Raycast). This only happens if the hoeTool is equipped and mouse.Target is “TillSpot”.
local hoeTool = script.Parent
local Players = game:GetService("Players")
local localPlayer = Players.LocalPlayer
local RS = game:GetService("ReplicatedStorage")
local RunService = game:GetService("RunService")
local UIS = game:GetService("UserInputService")
local PlaceholderDirt = RS.PlaceholderParts.PlaceholderDirt
local storedDirt = RS.Dirt
local tillSpot = workspace:WaitForChild("TillSpot")
local mouse = localPlayer:GetMouse()
local equipped = false
local hoveringOverTillspot = false
print("initialized TillingManager")
wait(1)
local function tillSpot()
local target = mouse.Target
if target and target.Name == "TillSpot" and equipped == true then
hoveringOverTillspot = true
local raycastParams = RaycastParams.new()
raycastParams.FilterType = Enum.RaycastFilterType.Exclude
raycastParams.FilterDescendantsInstances = {mouse.TargetFilter}
local mouseRay = Ray.new(mouse.UnitRay.Origin, mouse.UnitRay.Direction * 1000)
local mouseRayHitPart, mouseRayHitPosition = workspace:FindPartOnRayWithIgnoreList(mouseRay, {mouse.TargetFilter})
local placeholderClone = PlaceholderDirt:Clone()
placeholderClone.Parent = workspace.TillSpot
placeholderClone.Position = mouseRayHitPosition
wait(0.0001)
placeholderClone:Destroy()
else
print("arguments not matched, wrong target or unequipped during a RunStep")
hoveringOverTillspot = false
end
end
hoeTool.Equipped:Connect(function()
equipped = true
end)
hoeTool.Unequipped:Connect(function()
equipped = false
end)
RunService.RenderStepped:Connect(tillSpot)
mouse.Button1Down:Connect(function()
local hit = mouse.Target
if hoveringOverTillspot then
local newDirt = storedDirt:Clone()
newDirt.Parent = workspace.TillSpot
newDirt.Position = workspace.TillSpot:WaitForChild("PlaceholderDirt").Position
end
end)
I need to create a grid placement in increments of 5.5, my dirt part’s size is (5.5,1,5.5)
How would I do this? I know it involves rounding