So this is my datastore script. It is in the serverscriptservice with filtering enabled on. I do not have a playerleaving event. This is the script:
local SaveDataOne = game.ReplicatedStorage:WaitForChild("SaveData")
local DSService = game:GetService("DataStoreService")
local DS = DSService:GetDataStore("SupIWantToSave848837157")
local ChangeMoney = game.ReplicatedStorage.ChangeMoney
local GetMoney = game.ReplicatedStorage.GetMoney
local GetPlayers = game.ReplicatedStorage.GetPlayers
local ChangePlayers = game.ReplicatedStorage.ChangePlayers
local ChangeUpgrades = game.ReplicatedStorage.ChangeUpgrades
local ChangeRebirths = game.ReplicatedStorage.ChangeRebirhts
game.Players.PlayerAdded:Connect(function(plr)
wait(0.1)
local ids = "id-" .. plr.userId
local plrvalue = Instance.new("NumberValue", plr)
local monvalue = Instance.new("NumberValue", plr)
local UpgradeCounter = Instance.new("IntValue", plr)
local Rebirhts = Instance.new("IntValue", plr)
plrvalue.Name = "Players"
monvalue.Name = "Money"
UpgradeCounter.Name = "Upgrades"
Rebirhts.Name = "Rebirths"
local plrdata = DS:GetAsync(ids) or {0, 0}
if plrdata then
monvalue.Value = plrdata[1] or 0
plrvalue.Value = plrdata[2] or 0
UpgradeCounter.Value = plrdata[3] or 0
Rebirhts.Value = plrdata[4] or 0
ChangeMoney:FireClient(plr, monvalue)
ChangePlayers:FireClient(plr, plrvalue)
ChangeRebirths:FireClient(plr, Rebirhts)
wait(1)
print("Have data: 1. " .. monvalue.Value .. " 2. " .. plrvalue.Value)
else
monvalue.Value = 0
plrvalue.Value = 0
UpgradeCounter.Value = 0
Rebirhts.Value = 0
print("Saving data")
DS:SetAsync(ids, {monvalue.Value, plrvalue.Value, UpgradeCounter.Value, Rebirhts.Value})
print("Saved data")
end
end)
while wait(60) do
for i,v in pairs(game.Players:GetChildren()) do
local plrname = v
local id = "id-" .. v.userId
local money = plrname.Money
local plrd = plrname.Players
local Upgrades = plrname.Upgrades
local Rebirths = plrname.Rebirths
DS:SetAsync(id, {money.Value, plrd.Value, Upgrades.Value, Rebirths.Value})
end
end
Any help, please!
