Hi, I'm trying to learn how to use datastore 2, this is what I got and whenever I play and rejoin, it doesn't save. I can't test it on the studio as there is already a player in the Players section. So there wouldn't be any player added. Also, is it just me are is everyone having a new icon in the explorer name CorePackages that can't be deleted?
local DataStore2 = require(1936396537) DataStore2.Combine("MasterKey", "Kills", "Deaths", "Coins") game.Players.PlayerAdded:Connect(function(plr) local datakill = DataStore2("Kills", plr) local datadeath = DataStore2("Deaths", plr) local datacoin = DataStore2("Coins", plr) -- leaderboard local stats = Instance.new("Folder") stats.Name = "leaderstats" stats.Parent = plr local kills = Instance.new("IntValue") kills.Name = "Kills" kills.Parent = stats kills.Value = datakill:Get(0) local deaths = Instance.new("IntValue") deaths.Name = "Deaths" deaths.Parent = stats deaths.Value = datadeath:Get(0) local coin = Instance.new("IntValue") coin.Name = "Coins" coin.Parent = stats coin.Value = datacoin:Get(0) -- Save Kills datakill.Changed:Connect(function() datakill:Set(kills.Value) end) -- Save Deaths datadeath.Changed:Connect(function() datadeath:Set(deaths.Value) end) --Save Drachmas datacoin.Changed:Connect(function() datacoin:Set(coin.Value) end) -- On death event plr.CharacterAdded:Connect(function(char) local humanoid = char:FindFirstChild("Humanoid") humanoid.Died:Connect(function() deaths.Value = deaths.Value + 1 end) end) end)
Help please, Thank you!
This doesnt work because you are using require by the ID please read the documentation for that
https://devforum.roblox.com/t/how-to-use-datastore2-data-store-caching-and-data-loss-prevention/136317
also you are increasing every value by a plus not the :Increment() Function here is a thread in the DevForums which shows a basic solution for your question
https://devforum.roblox.com/t/not-showing-leaderstats-when-using-datastore2/399573/17