So I was trying to make a button green if the player has enough money and gray, if the player doesn't have enough money. The problem is, I can't compare his money value and the price of the item. The code looks like this:
-- Script game.Players.PlayerAdded:connect(function(plr) local money = plr:WaitForChild("leaderstats").Money.Value local bicyclePrice1T = math.random(2, 20) * 5 bicyclesImage.MouseButton1Down:connect(function() if money >= bicyclePrice1T then bBuyButton1A.BackgroundColor3 = BrickColor.Green().Color else bBuyButton1A.BackgroundColor3 = BrickColor.Gray().Color end end) end)
And it shows me this error:
10:33:09.862 - ServerScriptService.InternetScript:491: attempt to compare number with userdata
Thanks for reading
I fixed the problem:
-- Script game.Players.PlayerAdded:connect(function(plr) local money = plr:WaitForChild("leaderstats").Money local bicyclePrice1T = math.random(2, 20) * 5 bicyclesImage.MouseButton1Down:connect(function() if money.Value >= bicyclePrice1T then bBuyButton1A.BackgroundColor3 = BrickColor.Green().Color else bBuyButton1A.BackgroundColor3 = BrickColor.Gray().Color end end) end)
Scratch that, I actually needed to define the money and access its value while comparing it to bicyclePrice1T. Problem solved and now it works just fine.