I made a script but.. Locked and Unlocked works but it won't buy the gear i hope someone can help me Thanks

wait(5)
player = script.Parent.Parent.Parent.Parent.Parent.Parent
money = player.leaderstats.Level
price = 4 --Needed Level
tool = game.Lighting:findFirstChild("BlueStep")

function buy()
if money.Value >= price then
money.Value = money.Value - price
money.Value = money.Value + 4 --Keep the level
local a = tool:clone()
a.Parent = player.Backpack
local b = tool:clone()
b.Parent = player.StarterGear

end
end

while true do
	wait(2)
if money.Value >= 4 then --Up 4
	script.Parent.Text = "Unlocked"
else
	if money.Value <= 4 then --Under 4
		script.Parent.Text = "Locked"	
	end
end
end
script.Parent.MouseButton1Down:connect(buy)

1 comment

1

Because the while loop is preventing the script from reaching the connection line, move line 29 above the while true do loop. Or change the while true do loop to a Changed event for every time the 'money' value changes.