Part detecting terrain

Hi there!

This might be an easy answer, but I was wondering if there’s a way to know if a part has touched terrain. I’m making a game where you can shoot projectiles, and it’s a terrain map. Instead of having them go through (un-can collide), or bounce off (can collide). Appreciate all responses! :smiley:

2 Likes

You can use .Touched and :GetTouchingParts() as usual with terrain - it should work fine! If you have a code snippet that isn’t working for some reason, feel free to post it so we can take a closer look :slight_smile:

3 Likes

Thanks for the reply!

This is my code snippet (cleaned up to just the bare essential)

if hit.Name == "Wall" or hit.Name == "Tree" or hit.Name == "Mountain" or hit.Name == "Floor" or hit.Name == "Rocket" then
    rocketClone:Destroy()
end

As you can see I have an If statement to check what the name of the part the “rocket” is touching. It works for all of these exceptions (i.e. Wall, Tree, Mountain, Floor).

Still stumped as to how I could incorporate what you said into this. Apologies if it’s basic, and I’m not seeing it.

Thanks again!


if hit.Name == "Terrain" then
6 Likes

Wow, I could have sworn I tried this and it didn’t work. But now it does. I guess I messed something up the first time. Thanks for the reply. Truly appreciate it :slight_smile:

4 Likes

Don’t forget to mark @Elttob’s answer as the solution.

1 Like