How can I increment a player’s IntValue with DataStore2 in a different script?

Hello, everyone! This is just a simple question I have:

How would I change a player’s IntValue with DataStore2’s increment function?

I know that for DataStore2, Increment() can be used instead of changing a value by setting the player’s IntValue to the same value plus a certain number. However, the problem that I’m having is incrementing a value from a different script instead of the same script where I use DataStore service.

Do I have to define DataStore service in each script where I want a player’s IntValue to increment()?

If this was too hard to understand, here’s an example: I want to make the player’s cash value increase when they step on a block by using increment(), but I want to do this in a script in the block.

Pretty sure you just have to define DataStoreService again, or use ModuleScripts.

1 Like