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

Why doesn't this script change the GUI Color?

Inside of a Local Script, which is inside of a Text Button, I have the code:

if game.Players.LocalPlayer.leaderstats.Money.Value == 50 then
	script.Parent.BackgroundColor = BrickColor.new("Dark stone grey")
end

When the players money have reached 50 then the Text Button should become a grey color but doesn't. Why?

3 answers

✓ Accepted answer

GUIs use BackgroundColor3 as the background color. It's a Color3 rather than a BrickColor:

script.Parent.BackgroundColor3 = BrickColor.new("Dark stone grey").Color
-- or something like
script.Parent.BackgroundColor3 = Color3.new(.4,.4,.4)

I originally assumed you already had the work in to do this check properly, however, I just realized you probably don't.

The code you have almost would work, but it has to be checked frequently (as you have it written, it will only check once -- when the player spawns).

We should also check that they have at least (>= larger than or equal to) 50, rather than (==) exactly 50.

while wait() do
	if game.Players.LocalPlayer.leaderstats.Money.Value >= 50 then
		script.Parent.BackgroundColor3 = Color3.new(.4,.4,.4)
	end
end

3 comments

0

Blue nooo you beat me by one minute D: gg

0

It's not working still?

0

I expanded upon my answer

Try this:

if game.Players.LocalPlayer.leaderstats.Money.Value == 50 then
if script.Parent.BackgroundColor3 == (0, 0, 0) then-- Change this to the color that the Background Color is starting with
    script.Parent.BackgroundColor3 = Color3.new(0, 0, 0)--Change the 0's to your color the first zero is red, second 0 is green, and the third one is blue!
end
   end

If it doesn't work here I'll try doing something like it in a game of mine to see if I can find the problem.

Just shoot me a PM on roblox :)

7 comments

0

It's not working still?

1

Hmm let me take a look at it I'll edit it if I find an error I'm aware of how to fix :)

0

Could you tell me your output when the script is attempting to run. Also are you positive the parent of the script is the gui?

0

Sorry, it's a Text Label, not a Text Button.

0

The script outputs no errors. The tree goes StarterGui > Shop (Screen Gui) > Money (Text Label) > Local Script

0

I edited it a bit.

0

Also you could try the .Changed statement but I've never used it so you'll need to try out the wiki for that one.

Thx alot This worked :) "script.Parent.Parent.ObbyValue.BackgroundColor3 = Color3.new(.4,.4,.4)"

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