I tried to write a code that changes colour of a part if the player have enough money. I changed the code to print players money so i can see if it works. It works if the script is in StarterPlayerScript folder but it doesn't while in the part object. Game includes many parts in diffrent models and i thought that i must copy and paste this script into all parts that i want to change its colur depends on players money. Thanks and sorry for my poor English.
local player = game.Players.LocalPlayer local playermoney = player:WaitForChild("leaderstats").Money playermoney.Changed:Connect(function() print(playermoney.Value) end)
So in order to do this, you will need all the player's buy buttons grouped into a folder or model, it will just be a lot easier if you do this.
Next you just do what you already did, but include a loop to loop through the buy buttons and change the colors if the player has enough money.
local player = game.Players.LocalPlayer local playermoney = player:WaitForChild("leaderstats").Money local buttons = workspace[player.Name .. "BuyButtons"] --a folder named "SteamG0DBuyButtons, just create this in a server script when a player joins the game and put all of the tycoon's buy buttons in it. Do this if you don't already have something storing each person's buy buttons. playermoney.Changed:Connect(function() print(playermoney.Value) for i,v in pairs(buttons:GetChildren()) do if v.IntValue.Value < playermoney.Value then v.Color = Color3.fromRGB(0,0,0) end end end)
So i'm going to assume you have a value object in each button determining the cost of the button, and this script would go through those buttons, check the values in the buttons, and change the color of the button if the player has enough money.