In leaderstats are 3 intvalues (rocks wood and string) After collecting coins that increases value to the intvalues (in this case I would grab one coin that increases wood and one coin that would increase the rocks value increasing both the rocks and wood to 1000) After collecting these coins and leaving the game everything saves but one problem all values (the string included) somehow copy eachother when I never collected a coin that increases its value the string or the wood or rocks. If I were to collect two coins that increases rocks and make the rock's value 2000 but after I leave and join back it somehow copys its value and both wood and string have 2000. What is the problem?
game.Players.PlayerAdded:connect(function(p)
local WF = Instance.new("Folder")
WF.Name = "leaderstats"
WF.Parent = p
local Rocks = Instance.new("IntValue")
Rocks.Parent = WF
Rocks.Name = "Rocks"
local Wood = Instance.new("IntValue")
Wood.Parent = WF
Wood.Name = "Wood"
local Strings = Instance.new("IntValue")
Strings.Parent = WF
Strings.Name = "Strings"
end)
local players = game:GetService("Players")
local datastore = game:GetService("DataStoreService")
local ds1 = datastore:GetDataStore("Materials2")
players.PlayerAdded:connect(function(player)
local folder = player:WaitForChild("leaderstats")
folder.Name = "leaderstats"
folder.Parent = player
local currency1 = player.leaderstats.Rocks
currency1.Name = "Rocks"
currency1.Parent = player.leaderstats
currency1.Value = ds1:GetAsync(player.UserId) or 0
ds1:SetAsync(player.UserId, currency1.Value)
local currency2 = player.leaderstats.Wood
currency2.Name = "Wood"
currency2.Parent = player.leaderstats
currency2.Value = ds1:GetAsync(player.UserId) or 0
ds1:SetAsync(player.UserId, currency2.Value)
local currency3 = player.leaderstats.Strings
currency3.Name = "Strings"
currency3.Parent = player.leaderstats
currency3.Value = ds1:GetAsync(player.UserId) or 0
ds1:SetAsync(player.UserId, currency3.Value)
currency1.Changed:connect(function()
ds1:SetAsync(player.UserId, currency1.Value)
end)
currency2.Changed:connect(function()
ds1:SetAsync(player.UserId, currency2.Value)
end)
currency3.Changed:connect(function()
ds1:SetAsync(player.UserId, currency3.Value)
end)
end)

2 comments
well it would be better to save it as a table
Yes but in his case this is what he was asking. He needed help with his code erroring, not a whole new code.