Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Script not saving stats all the sudden?

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

You forget to put player variable.

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

end)

1 comment

0

Still not saving

This discussion is preserved as it was. New answers, comments, and votes are closed.