So I have this datastore but the problem is that it will create a value that I don't want! Help!?
local ds = game:GetService("DataStoreService") ds1 = ds:GetDataStore("popularity") ds2 = ds:GetDataStore("boost") ds3 = ds:GetDataStore("multiplier") game.Players.PlayerAdded:Connect(function(player) local leaderstats = Instance.new("Folder",player) leaderstats.Name = "leaderstats" local value = Instance.new("IntValue",leaderstats) value.Value = ds1:GetAsync(player.UserId) or 0 value.Name = "Popularity" -- Currency Name local value2 = Instance.new("IntValue",leaderstats) value2.Value = ds2:GetAsync(player.UserId) or 0 value2.Name = "Boost" local value3 = Instance.new("IntValue",leaderstats) value3.Name = "Multiplier" value3.Value = ds3:GetAsync(player.UserId) or 1 value.Changed:Connect(function() pcall(function() ds1:SetAsync(player.UserId,value.Value) end) end) value2.Changed:Connect(function() pcall(function() ds2:SetAsync(player.UserId,value2.Value) end) end) value3.Changed:Connect(function() pcall(function() ds3:SetAsync(player.UserId,value3.Value) end) end) game.Players.PlayerRemoving:Connect(function() pcall(function() ds1:SetAsync(player.UserId,value.Value) ds2:SetAsync(player.UserId,value2.Value) ds3:SetAsync(player.UserId,value3.Value) end) end) end)
by using this way it's more efficient.
local Data = game:GetService("DataStoreService"):GetDataStore("Data") local Save = "Save" game.Players.PlayerAdded:Connect(function(plr) local folder = Instance.new("Folder",plr) folder.Name = "leaderstats" local Popularity = Instance.new("IntValue",folder) Popularity.Name = "Popularity" local Boost = Instance.new("IntValue",folder) Boost.Name = "Boost" local Multiplier = Instance.new("IntValue",folder) Multiplier.Name = "Multiplier" local PlayerData = Data:GetAsync(Save .. tostring(plr.UserId)) if PlayerData then Popularity.Value = PlayerData[1] or 0 --change the 0 to your start value Boost.Value = PlayerData[2] or 0 Multiplier.Value = PlayerData[3] or 0 else Data:SetAsync(Save .. tostring(plr.UserId), { Popularity.Value, Boost.Value, Multiplier.Value }) end end) game.Players.PlayerRemoving:Connect(function(plr) Data:SetAsync(Save .. tostring(plr.UserId), { plr.leaderstats.Popularity.Value, plr.leaderstats.Boost.Value, plr.leaderstats.Multiplier.Value }) end)