Keeping a number value inside StarterCharacterScripts the same after respawning

Hello, I’ve recently made a script for an upgrades shop system for my FPS game. One of the upgrades that you can buy increases your gun’s total magazine size. I noticed that upon respawning, this upgrade doesn’t save and has to be purchased again. The gun’s total magazine size is handled by a number value, and upon purchasing this upgrade through a text button, the number value increases from 10 to 20. The number value itself is located in StarterCharacterScripts. I was wondering if there was any way for this number value to stay the same after respawning. Any help or tips is greatly appreciated!

Ah thanks so much man, this is exactly what I needed!

You should only save your values to a datastore when the user is leaving, making datastore requests everytime the player respawns is very inefficient. Instead, you should save the “Magazine Size” variable inside the player and not the character

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.