I currently have a tool which places itself in the direction of the player’s mouse.
My issue is that I can’t figure out how to make it so that the tool places only on the ground, and not on walls, ceilings or anywhere else.
I looked through some posts, but didn’t really find anything that helpful.
Here is an example of my code:
--**Local Script**
plr = game.Players.LocalPlayer
mouse = plr:GetMouse()
tool = script.Parent
tool.Activated:Connect(function()
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local RemoteFunction = ReplicatedStorage.SoilPlacement:WaitForChild("ClientToServer")
if RemoteFunction then
RemoteFunction:InvokeServer(mouse.Hit.Position)
end
end)
--**Server Script**
local tool = script.Parent
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local RemoteFunction = ReplicatedStorage.SoilPlacement:WaitForChild("ClientToServer")
use = true
RemoteFunction.OnServerInvoke = function(player, mouse_pos)
if use then
use = false
local Soil = tool.Handle:Clone()
Soil.Parent = game.Workspace
Soil.Name = "SoilPatch"
Soil.CanCollide = true
Soil.Anchored = true
Soil.Size = tool.Handle.Size
Soil.Position = mouse_pos
use = true
end
end
Any and all help is appreciated