Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

How can I set a text to a part's material name?

I used the following code:

TextLabel.Text = tostring(part.Material)

However, this sets the text to: 'Enum.Wood.Material', instead of 'Wood'. Is there a way to get the material name without having to use a 'if part.Material == Enum.Material.Wood then ..'?

1 answer

✓ Accepted answer

Use substrings.

print(string.sub(
	tostring(Enum.Material.Glass),15,20)
)
-- "Glass"

'Enum.Material.' takes up 15 characters, so it just comes down to finding everything after those.

1 comment

0

Ah, forgot about that thanks

This discussion is preserved as it was. New answers, comments, and votes are closed.