Best way to save items after buying an item from a shop?

What is the best way to save an item into an inventory system after buying an item from the shop? The best way in my context includes exploit free, not hard to script, and never fails on loading.

EDIT: Not saving tools, but saving themes and data like kill effects (even multiple items)

1 Like

server-sided stringvalue with jsonencode/decode

what is jsonencode/decode for?

Try using this open sourced model by @guywithapoo
Open Source Backpack Tool Saver - Resources / Community Resources - DevForum | Roblox

1 Like

Use datastores to save the items.

I’m not asking for an open sourced model and i’m only asking for ideas on finding the best way, plus i’m not actually saving tools, but saving values by stringvalues.

But how can I detect if the player bought an item from the shop in a localscript since using datastores are server side only.

I would store the items in a table, and when purchased I would add the plr in another table named savegoldweapon, and if they are in this table I give them the item.

I gotta change the description so I’m not trying to save tools, but saving themes and data like kill effects

How will I insert the items I bought into a table which the table is in a different script?

You can create Folders with values and save them.

If you included “the same thing” then, I’m also making it saves multiple items and not just one. Otherwise how can I detect a button mouse click which is in a local script, which then goes to the datastore in a server script to handle savings but still making it exploit free?

Remote functions and server checks.

Exploiter are also able to manually make remote functions to get the item too or even spam functions too even if it won’t give the item.

Okay so:

local item = "sword"  

Button.MouseButton1Click:Connect(function() 
game.ReplicatedStorage.YourRemoteFunction:InvokeServer(item) 
end) 

local script ^

local ItemCost = 150
local function ItemRemote(player, Item) 
if player.Money.Value >= ItemCost then
--give player item
         return true
        end
    return false 
end) 

game.ReplicatedStorage.YourRemoteFunction.OnServerInvoke = ItemRemote

Server script ^

This is probably impossible to exploit because you are checking the cost from server

Main:

local table = script.NameOfTheTableScript

– script of the main

Table script:

local table = {}

– table script here

How will saving work and make sure it never fails on loading? (Obviously using datastore but how?)

I would suggest you to learn object saving in DataStore for example AlvinBlox has good tutorial on this.

I’m going to leave that as a solution but I’m still looking for possible best ways although I don’t really have to.

1 Like

Like I said saving folders with ItemName and the folder will contain data about the Item is the best way.

2 Likes