Detect if NumberValue has gone up by 10

Is it possible to detect if a numbervalue has gone up by 10 everytime it has changed? Tried looking for a solution anywhere in here but couldn’t work, I’m asking this to avoid scenarios like this.

__KS.Changed:Connect(function(__INST)
		if __INST >= 10 then
			Player:WaitForChild("leaderstats"):WaitForChild("TIX").Value += 1200
			__TOG:FireClient(Player, "Bountry Award", "You have been awarded T$1200, for reaching 10 killstreak.", true)
		elseif __INST >= 20 then
			Player:WaitForChild("leaderstats"):WaitForChild("TIX").Value += 2400
			__TOG:FireClient(Player, "Bountry Award", "You have been awarded T$2400, for reaching 20 killstreak.", true)
		elseif __INST >= 30 then
			Player:WaitForChild("leaderstats"):WaitForChild("TIX").Value += 4800
			__TOG:FireClient(Player, "Bountry Award", "You have been awarded T$4800, for reaching 30 killstreak. The Maximum.", true)
		end
	end)

You can do something like this:

__KS.Changed:Connect(function(name)
    if name == "Value" then
        local tix = Player:WaitForChild("leaderstats"):WaitForChild("TIX")
        local earning = 0
        if __KS.Value == 10 or __KS.Value == 20 or __KS.Value == 30 then
            earning = __KS.Value / 10 * 1200
        end
        if earning > 0 then
            tix.Value += earning
            __TOG:FireClient(Player, "Bountry Award", "You have been awarded T$".. earning..", for reaching ".. _KS.Value.." killstreak.", true)
        end
    end
end)

You can check the modulus of 10:

__KS.Changed:Connect(function(__INST)
   if ((__INST % 10) == 0) and (__INST > 0) then
      -- Checks if __INST fits into 10 and is greater than 0
      -- ...
   end
end)
1 Like

Tried this one and it doesn’t seem to work… No errors either…

You can just store its previous value then when it’s changed, compare its new value to its old one.

local lastKS = __KS.Value
__KS:GetPropertyChangedSignal('Value'):Connect(function()
    local currentValue = __KS.Value
    if currentValue - lastKS >= 10 then -- it has increased by 10 since its previous change so
        -- in this block do your fireclient thing
    end
    lastKS = currentValue
end)

Also you can use this to remove the fireclient part, listen for the player’s tix value to change, compare the tix’s last value to its current value, and then you can show the player how much their tix has increased