Return Terrain material in mouse.Target

I have this tool that allows you to press a button, and it will print the material of the object being targeted.
However, when I print the material of terrain, it always returns as Plastic.

I’m not asking for help or a solution, but rather recommending, and pleading for ROBLOX to make this return the Material of the targeted terrain.
Thanks for your time :slight_smile:

1 Like

Is terrain’s material plastic? Is this a bug or something?

I don’t really get your question, can you clarify a bit thank you!

Remember that #development-support:code-review is for showing code that might efficient and finding a better way to run it

It might be more ideal to post this in #platform-feedback:studio-bugs if it’s a bug

1 Like

I don’t really have access to make post where I need to, so I try my best.

I will take your advice and attempt to put this in a bug topic.

Thank you! New members can’t post in various places, so what you can do is make your post in Bulletin Board, than send it to the post approval team

Check the guidelines and devforum rules for more info

1 Like

But just a plus, what we can do is use some raycasting to do this. Because :FindPartOnRat() returns the material of the object that was hit as a fourth value I think, we can even just check the material of what was hit.

I believe i tried this with another method, and the ray seemed to shoot right through the terrain, or it return plastic as well. (Can’t fully remember) despite me not coding it to do so… I’ve come across a few bugs with Terrain. Seems like it needs a bit a work.

I got around it by randomizing positions around the avatar, and placing a temporary mini-npc to read the FloorMaterial from it’s Humanoid. (This was a code to make the avatar wonder around the map.)

Of course I don’t think RayCasting is the problem, but rather the Terrain.

I’m going to link this post to my bug-report post so they can better understand.

Thanks to you, for your respectful help.

That would not be completely inconsistent with how roblox has the BasePart class set up and wouldn’t work for a variety of reasons, a big one being you are asking for function behavior (input, output) on a property.

Everyone knows the raycasting method is a bit annoying so perhaps a better request is for a better Terrain material method checking system.


Please be sure to review the Code Review category guidelines. Non-working code does not belong in Code Review, it should be posted in #development-support:scripting-support. You can move the topic by clicking the pencil beside the title.

As far as requesting a feature goes (which it seems like that’s where you’re headed), please see the Post Approval section of the rules.

As others have stated, use post approval. Behind the scenes the player mouse is using RayCasting from what I can tell. I have no idea what you’re using to find the Material of the target but RayCasting with the mouse is pretty simple.

The PlayerMouse Instance has a UnitRay property. You can construct a copy of this Ray with a custom magnitude like this:, Mouse.UnitRay.Direction*magnitude)

Now all you need to do is cast the Ray using FindPartOnRayUsingIgnoreList. The Mouse’s TargetFilter property should be included in the ignore list along with the character of the player.

Now you have all of the properties of Mouse and more. You’ll have access to the material returned by the RayCast which includes Terrain Materials.