How do I detect if someone is clicking near terrain water?

Hello, so I want people to be able to dig canals in my game, but if they’re trying to dig near water, instead of replacing where they click with air, I want to replace it with water, to simulate water flowing to the empty space.

Mainly I just want to know how I can figure out if where they click has a direct access to a water source, to see if water should generate rather than air.

Any help?

  • Luke
1 Like
  1. Create a part, this will be the detection part, this has to be a big sphere, make it transparent (.5 transparency for testing), anchored, CanCollide off, CanQuery off
  2. Have an area in the script which checks which parts touch the water
game.Workspace.Terrain.Appearance.Water:Touched:Connect(function(hit)

end)

OR loop through and check if the part is touching it.

game.Workspace.Terrain.Appearance.Water:GetTouchingParts()

(I am not 100% sure if you can check the parts which the sphere is touching, this might work as well.)

  1. If the hitpart and the detection bar are the same then cancel digging if they are not dont cancel
1 Like