So currently I have a working shop where players can purchase stuff, and when they do a remote is fired to the server for which sword that was, then if the player has the money it will clone the tool from the serverstorage into the player's backpack. What I wanted to do is make it so these tools are saved and when a player joins the game automatically gives them their purchased tools.
My original idea was to have a bool value inside each tool in the serverstorage to check whether it had been purchased or not, but then I realised if I do that then when the value changes, the tool will show as bought for everyone? Sorry if that's confusing, just advice on how to begin creating this sort of system?
Try this:
local ItemStore = game:GetService("DataStoreService"):GetDataStore("Items") local Items = {plr.Backpack:FindFirstChild("")} --Add the name of the item and if you want to add more just do: , plr.Backpack:FindFirstChild("") and add the name of the other item game.Players.PlayerAdded:Connect(function(plr) local vSave = ItemStore:GetAsync(PlayerKey) if vSave then Items = vSave[1] else ItemStore:SetAsync(PlayerKey, {Items}) end end) game.Players.PlayerRemoving:Connect(function(plr) local PlayerKey = "player-"..plr.UserId ItemStore:SetAsync(PlayerKey, {Items}) end)
Put this in a script, If it works please click accept answer.
--MajinBluee
Check out this answer
that I gave to another scripter. Hope it helps. Have a great day scripting!