I’m trying to make a tool that can build terrain.
I have this part that shows where you can build and I’m moving it to the mouse using Mouse.Hit.Position
but it keeps moving up off the ground like this
How do I stop it from doing this?
Here’s my code so far:
local tool = script.Parent
local plr = game.Players.LocalPlayer
local mouse = plr:GetMouse()
local PlacementIndicator = game.ReplicatedStorage:FindFirstChild("PlacementIndicator")
local equipped = false
local currentIndicator
tool.Equipped:Connect(function()
equipped = true
currentIndicator = PlacementIndicator:Clone()
currentIndicator.Parent = workspace
while equipped == true do
currentIndicator:MoveTo(Vector3.new(math.round(mouse.Hit.Position.X), math.round(mouse.Hit.Position.Y), math.round(mouse.Hit.Position.Z)))
wait()
end
end)
tool.Unequipped:Connect(function()
equipped = false
currentIndicator:Destroy()
end)