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)
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.
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.
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?
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