Script help, needed - Value is lost 2x

local function Consume()
		if consumeDebounce == false then
			consumeDebounce = true
			if NumOfUses.Value > 0 then
				ConsumeTrack:Play()

				if ConsumableType.Value == "Water" then--THIRST CONSUMABLE
					ConsumeTrack:GetMarkerReachedSignal("Consumed"):Connect(function()
						if NumOfUses.Value >= ConsumeSubtract then
							NumOfUses.Value = NumOfUses.Value - ConsumeSubtract
							print(NumOfUses.Value)
							Thirst.Value += AmountGiven.Value
							ConsumedSFX:Play()
							VisualWater()
						end
					end)
				end
			end
			task.wait(6)
			consumeDebounce = false
		end
	end

To describe it better than the title, this functions works fine when the user uses it once which triggers “Consume()”, It will only remove one point from the NumsOfUses, but when they use it a second time it starts remove two points from the NumsOfUses, Only way Ive found a way to resolve this issue through removing

ConsumeTrack:GetMarkerReachedSignal("Consumed"):Connect(function()

but this is not ideal for a multitude of reason.

Another thing to note

	Consumable.Unequipped:Connect(function()
		ConsumeTrack:Stop()
	end)

also seems to prevent the issue, should I unequip and re-equip and drink it

1 Like

try replacing the :Connect in the ConsumeTrack:GetMarkerReachedSignal("Consumed") with :Once

1 Like

I love you so much bro

(dasjdqi)

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