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

How to find the difference between the current money, like in the simulators?

I'm currently developing a simulator, when you gain money a small gui will pop up a random place on your screen that is a textlabel indicating how much you gained in terms of money / cash.

I've tried searching on youtube but with no good result. I've also tried the code myself:

Now that I'm asking for something i don't want you to do the popup and the design, i just want a simple print(amount), and i can program it myself from there.

It's a IntValue, so i tried using .Changed, or :PropertyChangedSignal(), thank you for reading.

1 answer

✓ Accepted answer

Obviously, in order for this to happen you probably have at least one function somewhere that adds money to the player's balance, right?

You can take a far simpler approach and, when you fire the RemoteEvent to the client to make the ScreenGui appear, just pass the amount of money added as an argument and go from there.

However, if for some odd reason you really want to do it the way you talked about, here's how I would do it:

local previousAmount = 1000 -- Variable holds the amount of money the player has before any transactions. I wrote 1000 as a starting amount

Money.Changed:Connect(function(newValue)
	print(newValue - previousAmount) -- This'll tell you how much was gained.
end)

The code I just wrote isn't perfect though and there's ways it can go wrong, which is why I suggest doing the first thing I talked about instead.

1 comment

1

To the point, broad, helpful. Thank you for sharing this with me! :)

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