Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Script not saving stats all the sudden?

Asked by
Vxpper 101
4 years ago

So, since I added the "MyCrates" variable, this script has not been saving, any ideas why?

local datastore = game:GetService("DataStoreService")
local MyMoney = datastore:GetDataStore("MoneyData")
local MyRuby = datastore:GetDataStore("RubyData")
local MyCrates = datastore:GetDataStore("CrateData")

game.Players.playerAdded:connect(function(player)
    local Money = Instance.new("IntValue", player)
    Money.Name = "Money"
    local Ruby = Instance.new("IntValue", player)
    Ruby.Name = "Rubys"
    local Crate = Instance.new("IntValue", player)
    Crate.Name = "Crates"

    Money.Value = MyMoney:GetAsync(player.UserId) or 1000 
    MyMoney:SetAsync(player.UserId, Money.Value) 
    Ruby.Value = MyRuby:GetAsync(player.UserId) or 10
    MyRuby:SetAsync(player.UserId, Ruby.Value)
    Crate.Value = MyCrates:GetAsync(player.UserId) or 0
    MyCrates:SetAsync(player.UserId, Crate.Value)

game.Players.PlayerRemoving:connect(function()
    MyMoney:SetAsync(player.UserId, Money.Value) 
    MyRuby:SetAsync(player.UserId, Ruby.Value)
    MyCrates:SetAsync(player.UserId, Crate.Value)
    end)
end)

1 answer

Log in to vote
0
Answered by
OnaKat 444 Moderation Voter
4 years ago

You forget to put player variable.

game.Players.PlayerRemoving:Connect(function(player) -- Here

end)
0
Still not saving Vxpper 101 — 4y
Ad

Answer this question