Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

[SOLVED] What is the best way to tell if a value has been subtracted from?

What is the best way to tell if a value has been subtracted from?

I have some ideas like this one, for instance:

local number = game.Workspace.Number
local prevnumber = number.Value

number.Changed:connect(function()
	if number.Value < prevnumber then
		print("Number is smaller than prevnumber")
	end
end)

But what I really want to know is if there is any other more efficient way to tell if a value has ben subtracted from.

Any help is greatly appreciated!

1 answer

No

There is genuinely no better way to tell if it has been subtracted from than to check. Mind, your example code is wrong.

local num = workspace.Number;
local prev = num.Value;

num.Changed:connect(function(val)
  if prev > val then
    -- Subtracted from
  end
  prev = val; -- Make sure that you update the old value
end);

1 comment

0

Thanks, but I already figured it out. :-)

This discussion is preserved as it was. New answers, comments, and votes are closed.