Script Skips all parts and only applies the script to 1 part

im making a button simulator and trying to make so when you have enough cash to buy it becomes neone but it only applies to 1 button

Script:

game.Players.PlayerAdded:Connect(function(plr)

local MainStats = plr:WaitForChild("MainStats")
local Cash = MainStats.Cash


local MBF = game.Workspace.Buttons


	for _,Button in MBF:GetChildren() do
		if Button:IsA("Folder") then
			local Base = Button:WaitForChild("Base")
			local Btn = Base.Btn

			local Config = Base.Config
			local Price = Config.Price


			local function MNeon()
				if Cash.Value >= Price.Value then
					Btn.Material = "Neon"
				end
			end
			while wait() do
				MNeon()
			end
		end
	
	end


	end)

try this instead:

--Other lines of code...
			local function MNeon()
       while task.wait() do
				if Cash.Value >= Price.Value then
                
					Btn.Material = "Neon"
                    
                 end
				end
			end
			task.spawn(MNeon)

As I understand it, The base has many buttons?

Edit: maybe try this?

yeah you put it as a while loop so its still doing the same part forever

have a lot of folders inside is a base and inside are the btn and other stuff

No the base has 1 buttons but there are a lot of folders with base inside of them

Yea, I just realized that. I removed the for i, v loop

i meant the OP not you btw

characters,characters,characters 30

1 Like

yeah it works now ill go try to make so when u dont have enough(rebirthed etc) neon will be gone

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.