I have a number value that I subtract a given number from when a mouse is clicked and just automatically. The problem is, though, that occasionally I subtract a number more than once very close in time to each other in two different scripts. The value, instead of combining both numbers that are being subtracted, only subtracts one of the numbers. Why is this happening?
Script #1
local value = game.Workspace.NumberValue.Value -- let's assume value is 30
local randomNumber = 5
function Down(mouse) -- assuming the mouse is clicked very close to the time before randomNumberTwo is subtracted from the value in script #2 and very close to the time after randomNumberTwo is subtracted
value = value - randomNumber
print(value)
end
function Selected(mouse)
mouse.Button1Down:connect(function() Down(mouse) end
end
-- Output = 25
Script #2
local randomNumberTwo = 10
local value = game.Workspace.NumberValue.Value -- since only 1 mouse click has occured, the value should now be 25
wait(3)
value = value - randomNumberTwo
print(value)
-- Output = 20 | the output should be 15, but it's not

3 comments
Hm, I tried that, and the same problem still occurs.
There was a syntax mistake in #1, a missing closing ')' bracket. Also, I didn't write "print(numberValue.Value)" but rather "print(value)" which was a mistake. You should be able to correct those mistakes yourself, though. I tested them and they work as expected.
What I have explained is most definitely a solution to the question you asked. If you expect others to answer your questions in future you should contribute to the system by choosing this as the answer to your question. Thanks!