How do I make the colour of a Button change when a certain Tool has been found in the players backpack?

Hi scripters,

I am struggling to find out how to make a GUI button change colour when a certain Tool has been found in the players backpack. I am a beginner at scripting.

You can check when an instance (the tool) has been added into the backpack using ChildAdded. If the instance matches what you’re looking for, then you can color the button accordingly.

1 Like

Hi,

Thanks for your reply can you give me and example on how I should write the script?

This isn’t complete code, but it illustrates the idea of my previous reply.

game:GetService("Players").LocalPlayer.Backpack.ChildAdded:Connect(function(child)
       if child and child.Name == --[[Whatever tool name--]] then
             -- Color GUI element here
       end
end)

I am going to show you what is going wrong with my script is there any way I can fix this:

So if the player has a tool named “Apple Noob” You want the button gui to be completely destroyed. And what does it say into the output when you test this?

It doesn’t say anything in the Output :frowning:

Ok, so in the code after if and then statement before the button is destroyed put Print("Found") then after destroyed put it after the button being destroyed Print("Was Destroyed")

Hello,

It isn’t printing anything?

Here is an image on what I wrote:

put the first print(“found”) On a new line otherwise it won’t work as well, indenting and putting your codes on different lines are very important.

Hi I have moved the print however it still isn’t quite working.

It hasn’t said anything in the output either: