local dataStoreService = game:GetService("DataStoreService")
local yuanData = dataStoreService:GetDataStore("YuanData")
local killsData = dataStoreService:GetDataStore("KillsData")
game.Players.PlayerAdded:Connect(function(plr)
local leaderstats = Instance.new("IntValue", plr)
leaderstats.Name = "Stats"
local yuan = Instance.new("IntValue", leaderstats)
yuan.Name = "Yuan"
yuan.Value = yuanData:GetAsync(plr.UserId) or 0
local kills = Instance.new("IntValue", leaderstats)
kills.Name = "Kills"
kills.Value = killsData:GetAsync(plr.UserId) or 100
local element = Instance.new("StringValue", leaderstats)
element.Name = "Element"
element.Value = "None"
local gp = Instance.new("IntValue", plr)
gp.Name = "Gamepasses"
local bFire = Instance.new("BoolValue", gp)
bFire.Name = "BlueFire"
bFire.Value = false
end)
game.Players.PlayerRemoving:Connect(function(plr)
local yuan = plr.Stats.Yuan
yuanData:SetAsync(plr.UserId,yuan.Value)
end)
so right now I want to only save the "Yuan" variable and whenever I change it in player stats it doesn't save and idk why.

3 comments
when the server shuts down? what about if the player leaves and joins another server but the previous server didn't shut down, will the data still be saved??
tested it and it still doesn't work
If the player isn't the last player in the server and they leave, they are fine.