Change Color script

Hello everybody! Today I was working on my obby, and I wanted to make a stage where I have frogs, and there are like 30 frogs, and only 6 are not killparts. I wanna make it so it shows which frog is not the killpart. So it will make the frog green then it will show the other frog etc. The whole frog is a Mesh so I want the texture to reset back to normal after the frog has been shown. I am trying to make it do that but I can’t because I keep getting this error (" [TextureID is not a valid member of Part"). I didn’t complete the script but I did one frog and I went to go test it out but it didn’t work. Does anyone know how to fix this? btw my script is in ServerScriptService. This is the script that I started working on…

I am still pretty new to scripting, so if you could explain it in a beginner way, that would be great! :)))

Parts do not have a TextureID property, but Texture does.

Take a look at me!

2 Likes

As a good habit and practice, load your list of frogs into a table.

And on loop run through your table of them. Its good to start getting practice using tables even at a very basic level you will need to get very comfortable with them.

Because of how Roblox Studio handles errors, this one is wrong. What you intend to do is more than likely to change the TextureID of a part, yet the problem is that it does not have any property called “TextureID” - which in this case, it should have said “TextureID is not a property of Part” in order to explain it better.

But let’s get to the point: Part Instances don’t really have a property called "Texture ID"s, but as @PhoenixRessusection said, Texture instances do (check out the texture link Phoenix linked).

It is also a good practice to place your frogs in a table like this:

local Frogs = {
   Frog1 = workspace.SafeFrog1;
   Frog2 = workspace.SafeFrog2;
   Frog3 = workspace.SafeFrog3;
   --and such

};

Which can also be useful for when you are trying to change a color of a part, using a for loop.

1 Like

Thanks dude, this helped.

I did do local texture = instance.new(“Texture”) And I still got an error. But I don’t really know how to use it when doing it with an instance. There is so much I don’t know how to do that the most simple stuff is hard.

Thanks bro, will do. When you make a table, can I just pull safefrog1 out of the table or will I have to call it has frog? To better explain. local frog, is a variable and all my stuff goes into that table. So when I want a certain “frog” can I just call it by it’s name?

You can do local frog = Frogs.Frog1 to reference the first frog.

By the way, we can make the table fully dynamic by putting the frogs in a folder and running :GetChildren() on the folder which returns an array of the children.

Alright thanks, No one really has answered the color changing part tho… or has explained it in a way that I could see. Or even an example. Because the frogs are meshparts.

local texture = Instance.new("Texture")
local Pumps = {
pumpkin1 = workspace.Pumpkin1;
pumpkin2 = workspace.Pumpkin2;
pumpkin3 = workspace.Pumpkin3;
pumpkin4 = workspace.Pumpkin4;
pumpkin5 = workspace.Pumpkin5
}```

would it be something like this?

Correct. You would have more possibilities if you placed it like that, even use a for loop

However like @COUNTYL1MITS said, it would be much more effective to put the frogs in a folder and then use the method :GetChildren to automatically get an iterated table of the frogs easily, without having to place them each line in a table

mk, thanks for the help. SO now I would just do

while true do
Pumps.pumpkin1.texture = " " --textureID goes here

--all the rest of the code will go here

end

Yeah, you got it. Although it wouldn’t really be a good idea to just keep a while true do loop just to change the color or texture of a part over and over. Instead, you should also place the IDs in a table, and then run a for loop in a while loop.

ok, thanks man! Thanks for being patient with me :)) have a good day!

I also think that it was causing an error because those meshes were not mine.