Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How do i save player items/weapons with datastore?

Asked by 6 years ago

so i have it set up to where it saves exp/gold/level but im not quit sure how to save their items because they will have the one that is equipped in their character model, but all of the other items will be in their backpack?

local leveldata = game:GetService("DataStoreService"):GetDataStore("level")
local EXPdata = game:GetService("DataStoreService"):GetDataStore("EXP")
local xpLeveldata = game:GetService("DataStoreService"):GetDataStore("xpLevel")
local Golddata = game:GetService("DataStoreService"):GetDataStore("Gold")
local weapondata = game:GetService("DataStoreService"):GetDataStore("weapons")
local HttpService = game:GetService("HttpService")

game.Players.PlayerRemoving:Connect(function(player) -- save player stats
    savedata('weapons',playerKey,player.Backpack)
    savedata('weapons',playerKey,player.Character:FindFirstChildOfClass('Tool'))
    savedata('level',playerKey,player.leaderstats.Level.Value)
    savedata('EXP',playerKey,player.Exp.Value)
    savedata('xpLevel',playerKey,player.ExpNeeded.Value)
    savedata('Gold',playerKey,player.leaderstats.Gold.Value)
end)

this setup im using works for all of the above except weapons. if anyone knows what im doing wrong pls help and thank you!

Answer this question