Not enough value wont enable the script, and remove value!

Howdy DevForum! I am try to make it so that when you touch this button it enables a script and subtracts value from the IntValue. But I want to make it so if you dont have enough it wont work! Please help! This is a regular script.

local db = false
script.Parent.Touched:Connect(function()
	if db == false then
		db = true

		script.Parent.Parent.Parent.AmountBoard.AmountDisplayPart.Amount.Value -= 15
		script.Parent.Touched:Connect(function()
			script.Parent.Parent.Parent.Tree2.AddValue.Disabled = false
		end)
		wait(5)
		db = false
		end
end)
1 Like

You can do a check like this:

local db = false

script.Parent.Touched:Connect(function()
	if db == false and script.Parent.Parent.Parent.AmountBoard.AmountDisplayPart.Amount.Value >= 15 then
		db = true

		script.Parent.Parent.Parent.AmountBoard.AmountDisplayPart.Amount.Value -= 15
		script.Parent.Touched:Connect(function()
			script.Parent.Parent.Parent.Tree2.AddValue.Disabled = false
		end)
		wait(5)
		db = false
	end
end)