Can you tell me why this isn't working?
local DataStoreService = game:GetService("DataStoreService")
local store = DataStoreService:GetDataStore("PLSHELP")
local function leaderstat(plr)
local leader = Instance.new("Folder")
leader.Name = "leaderstats"
leader.Parent = plr
local lettrboyos = Instance.new("IntValue")
lettrboyos.Name = "Letters"
lettrboyos.Parent = plr.leaderstats
lettrboyos.Value = DataStoreService:GetAsync(plr.UserID) or 0
DataStoreService:SetAsync(plr.UserID,lettrboyos.Value)
lettrboyos.Value.Changed:Connect(function()
DataStoreService:SetAsync(plr.UserID,lettrboyos.Value)
end)
local heartstaken = Instance.new("IntValue")
heartstaken.Name = "Hearts"
heartstaken.Parent = plr.leaderstats
heartstaken.Value = DataStoreService:GetAsync(plr.UserID) or 0
DataStoreService:SetAsync(plr.UserID,heartstaken.Value)
heartstaken.Value.Changed:Connect(function()
DataStoreService:SetAsync(plr.UserID,heartstaken.Value)
end)
game.Players.PlayerRemoving:Connect(function()
DataStoreService:SetAsync(plr.UserID,lettrboyos.Value)
DataStoreService:SetAsync(plr.UserID,heartstaken.Value)
end)
end
game.Players.PlayerAdded:Connect(leaderstat)

2 comments
It doesn't work because you are overriding the data in the database. You need either 2 separate databases or another key to separate them.
how would I go about doing this? Sorry am new to lua