Hello, I have a shop system with weapons, and once a player purchases a weapon, the weapon’s ID is stored in the player’s data store. I want to make it so that after the player purchases a weapon, the button text changes to “Equip,” and the player can equip or unequip the weapon if they own it. How should I implement this?
I tried implementing it using boolean values on the button. If the button’s boolean value is true, the player can’t trigger the purchase event because it requires the value to be false. But I’m kind of stuck on this . Maybe there’s an easier way?
You could use a remote to a server script to check if the weapon id is present in the players datastore. If the weapon id is in the datastore, then the script returns true and then u can decide wether or not the weapon can be equipped or not.
Additionally, we don’t want to request to the server too much, so you should only fire a remote to the server once.
The server script should loop through the players data and return a table with all of the weaponId’s info, such as if the player owns it or not.
if you only save the weaponid’s that the player owns, then you can just return a table of the weaponid’s then allow the player to equip whatever weapon (using the weaponId’s) inside the table.
Maybe it’s better to create an inventory GUI, and when the player purchases a weapon, add its ID to the player data. Then, upon joining, the inventory can be set up for the player, and when they buy something new, it will update the inventory, instead of handling equip/unequip directly in the shop GUI ?