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?
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
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 :)
Thx alot This worked :) "script.Parent.Parent.ObbyValue.BackgroundColor3 = Color3.new(.4,.4,.4)"