I have some code and I don't know why it doesn't work. Help?
t = script.Parent.Parent.Parent.CurrencyToCollect.Value function MoneyBin() script.Parent.Treasure:ClearAllChildren() if t > 0 and t <= 500 then game.Lighting.t1:Clone().Parent = script.Parent.Treasure elseif t > 500 and t <=1000 then game.Lighting.t2:Clone().Parent = script.Parent.Treasure end end script.Parent.Parent.Parent.CurrencyToCollect.Changed:connect(MoneyBin)
I believe the problem is your code states the value currency before hand. The code doesn't re-check for if the currency each time the event is fired. Therefore, the script just thinks the currency is 0 or whatever the starting value is.
How to fix this is removing the .Value
off the variable and the if statement needs to check for the new currency value each time it gets fired.
local t = script.Parent.Parent.Parent.CurrencyToCollect function MoneyBin() script.Parent.Treasure:ClearAllChildren() if t.Value > 0 and t.Value <= 500 then game.Lighting.t1:Clone().Parent = script.Parent.Treasure elseif t.Value > 500 and t.Value <=1000 then game.Lighting.t2:Clone().Parent = script.Parent.Treasure end end script.Parent.Parent.Parent.CurrencyToCollect.Changed:connect(MoneyBin)