I want it so when the player has enough money, the parts material will change to neon
The material changing is inconsistent and broken, most of the time only one button will glow, other times maybe 2 will glow but they will not update based on the players cash
while wait(0.1) do
local mult = game.Workspace.Buttons.Base.Multi
local plr = game.Players.LocalPlayer
local stat = plr:WaitForChild("Data"):WaitForChild("Stats"):WaitForChild("Money")
local x = require(game.ReplicatedStorage.EternityNum)
for _, button in mult.Mul.Glow:GetChildren() do
local buttons = mult.Mul
local config = buttons.config
if x.meeq(x.convert(stat.Value), (x.convert(config.cost.Value))) then
button.Material = Enum.Material.Neon
else
button.Material = Enum.Material.SmoothPlastic
end
end
end
local mult = game:GetService(“Workspace”):WaitForChild(“Buttons”):WaitForChild(“Base”):WaitForChild(“Multi”)
local plr = game:GetService(“Players”).LocalPlayer
local stat = plr:WaitForChild(“Data”):WaitForChild(“Stats”):WaitForChild(“Money”)
local x = require(game.ReplicatedStorage.EternityNum)
while wait(0.1) do
local GlowChildren = mult.Mul.Glow:GetChildren()
for _, button in pairs(GlowChildren) do
local buttons = mult.Mul
local config = buttons.config
if x.meeq(x.convert(stat.Value), x.convert(config.cost.Value)) then
button.Material = Enum.Material.Neon
else
button.Material = Enum.Material.SmoothPlastic
end
end
end
Why:
I think base on your script the variable doesn’t need to update at this point so I put it on the top and added some “:WaitForChild(”“)” to wait for its child before proceeding.
here in “for _, button in mult.Mul.Glow:GetChildren() do” i change it into " local GlowChildren = mult.Mul.Glow:GetChildren()
for _, button in pairs(GlowChildren) do" so the Glow’s children will save in GlowChildren and loop all things inside it. hopes this helps
The problem is pretty simple, you are iterating just one pad’s children. From my understanding the Multi folder contains all the pads models. If that’s the case then the correct way of iterating is:
for _, pad in pairs(mult:GetChildren()) do
for _, button in pad.Glow:GetChildren() do
local buttons = mult.Mul
local config = buttons.config
if x.meeq(x.convert(stat.Value), (x.convert(config.cost.Value))) then
button.Material = Enum.Material.Neon
else
button.Material = Enum.Material.SmoothPlastic
end
end
end
My bad, forgot to change the variable used to get config
for _, pad in pairs(mult:GetChildren()) do
for _, button in pairs(pad.Glow:GetChildren()) do
local config = pad.config
if x.meeq(x.convert(stat.Value), (x.convert(config.cost.Value))) then
button.Material = Enum.Material.Neon
else
button.Material = Enum.Material.SmoothPlastic
end
end
end
Anwyay you should revise your variables naming because it’s very confusing.