Entity:SetSubMaterial() isn't valid function!!!

Everytime I try to use Entity:SetSubMaterial() or Entity:GetSubMaterial() it just errors and says it’s a nill value even when I set right arguments

Does anybody know what’s going on?


It’s only in the dev branch, Robotboy always documents the functions on the wiki in advance.
The update should hit soon hopefully, in the meantime just switch to the dev branch to develop your script.

Uh, and is there any way how else could I modify the certain material on a model with multiple materials on it?

Nope, that’s why that binding was added.

Change your game to the dev branch and you’ll have it :v:

You can, but it isn’t the easiest thing to do. Take a look at this: https://dl.dropboxusercontent.com/u/26074909/tutoring/map_textures/replacing_textures_in_realtime.lua.html

It is like that, but EVERYTHING needs to be managed; the script above replaces them once and overwrites values. For you to have the same functionality as the functions now in dev version, it becomes a lot more involved ( I know because I made a clothes system shortly before those functions were added, and someone I know made one before me using different methods ).

Basically, before the model is rendered you’d temporarily overwrite the current textures, and after the model is drawn, you replace the replaced textures with the originals ( which is why you need to remember / store all old details ). If done incorrectly then the texture is replaced permanently and you’d need to restart the game / rejoin for them to be back to normal.