So I made this beautiful code that doesn’t work. Basically, your data isn’t carrying over between sessions. I don’t know if it’s failing to save and is loading default data or if it’s saving successfully but not loading your saves. Maybe I’m missing something that I can’t see.
local dataStore2 = require(1936396537)
dataStore2.Combine("MasterKey", "PlrKills", "PlrDeaths", "PlrTickets", "PlrLastJoin", "PlrPlaylist2", "PlrTools", "PlrSettings")
game.Players.PlayerAdded:Connect(function(player)
player.CharacterAppearanceLoaded:Wait()
local stats = Instance.new("Folder", player)
stats.Name = "leaderstats"
local kills = Instance.new("IntValue", stats)
kills.Name = "Kills"
local deaths = Instance.new("IntValue", stats)
deaths.Name = "Deaths"
local tickets = Instance.new("IntValue", stats)
tickets.Name = "Tickets"
local streak = Instance.new("IntValue", stats)
streak.Name = "Streak"
local lastKill = Instance.new("ObjectValue", stats)
lastKill.Name = "LastKill"
local playerKills = dataStore2("PlrKills", player)
playerKills:OnUpdate(function(newStat)
kills.Value = playerKills:Get(newStat)
end)
kills.Value = playerKills:Get(0)
local playerDeaths = dataStore2("PlrDeaths", player)
playerDeaths:OnUpdate(function(newStat)
deaths.Value = playerDeaths:Get(newStat)
end)
deaths.Value = playerDeaths:Get(0)
-----------------------------------------------------------------------------------------------------------------------------------
local playerTickets = dataStore2("PlrTickets", player)
local playerLastJoin = dataStore2("PlrLastJoin", player)
playerTickets:OnUpdate(function(newTix)
tickets.Value = newTix
end)
tickets.Value = playerTickets:Get(0)
local dailyReward = 0
local lastReward = playerLastJoin:Get(0)
if os.time() - lastReward / 3600 > 23 then
dailyReward = 10
if player:IsInGroup(9152847) then
dailyReward = dailyReward * 10
end
if game:GetService("MarketplaceService"):UserOwnsGamePassAsync(player.UserId, 14051142) then
dailyReward = dailyReward * 10
end
playerTickets:Increment(dailyReward, 0)
playerLastJoin:Set(os.time())
end
-----------------------------------------------------------------------------------------------------------------------------------
local playerPlaylist = dataStore2("PlrPlaylist2", player)
local playerTools = dataStore2("PlrTools", player)
local playerSettings = dataStore2("PlrSettings", player)
local myTools = tools
if IsVIP(player.UserId) then myTools = tools2 end
game.ReplicatedStorage.UpdatePlayer:FireClient(player, {
playerPlaylist:Get(songs),
playerTools:Get(myTools),
playerSettings:Get({70, -10})
})
Like, this should work. Meanwhile, I tested the code below in a different game, and it worked perfectly.
local dataStore2 = require(1936396537)
dataStore2.Combine("DATA", "hi", "yo", "holla", "PlrDeaths")
game.Players.PlayerAdded:Connect(function(player)
local l = Instance.new("Folder", player)
l.Name = "leaderstats"
local deaths = Instance.new("IntValue", l)
deaths.Name = "Deaths"
local playerDeaths = dataStore2("PlrDeaths", player)
playerDeaths:OnUpdate(function(val)
deaths.Value = val
end)
deaths.Value = playerDeaths:Get(0)
player.CharacterAdded:Connect(function(character)
character:WaitForChild("Humanoid").Died:Connect(function()
playerDeaths:Increment(1, 0)
end)
end)
end)
The “hi, yo, holla” is only there because I had a feeling that it wasn’t working because I was trying to combine multiple keys at once. I was wrong. Anyway, any help would be greatly appreciated. <3