So yeah, as you can see from this script below, I really do not understand Datastore that well. I've got 2 other scripts that follow the same thing, but one uses numbers instead.
For what this is, these variables check if you have a piece of cosmetic. One of these gets checked to true after a chance when you win a game. What cosmetic you've equipped is in another script though that uses a similar structure to this one.
The error here is probably very obvious if you know how Datastores work. But this works well until a third player enters the server. When a third player enters, the datastore throttles (that's what i think it is?) and they end up not getting their variables correctly. I went quite far with this until I decided to test it.
local data = game:GetService("DataStoreService")
local date = data:GetDataStore("Verbas2")
local key = "play_"
game.Players.PlayerAdded:connect(function(plyr)
local a=Instance.new("Folder")
a.Parent=plyr
a.Name="Hat"
local stat1=Instance.new("BoolValue") -- every variable from here on is just to check if you have the item
stat1.Value=date:GetAsync(key.."1"..plyr.UserId, stat1.Value)
stat1.Parent=a
stat1.Name="S1"
local stat2=Instance.new("BoolValue")
stat2.Value=date:GetAsync(key.."2"..plyr.UserId, stat2.Value)
stat2.Parent=a
stat2.Name="S2"
local stat3=Instance.new("BoolValue")
stat3.Value=date:GetAsync(key.."3"..plyr.UserId, stat3.Value)
stat3.Parent=a
stat3.Name="S3"
local stat4=Instance.new("BoolValue")
stat4.Value=date:GetAsync(key.."4"..plyr.UserId, stat4.Value)
stat4.Parent=a
stat4.Name="H1"
local stat5=Instance.new("BoolValue")
stat5.Value=date:GetAsync(key.."5"..plyr.UserId, stat5.Value)
stat5.Parent=a
stat5.Name="F1"
local stat6=Instance.new("BoolValue")
stat6.Value=date:GetAsync(key.."6"..plyr.UserId, stat6.Value)
stat6.Parent=a
stat6.Name="T1"
local stat7=Instance.new("BoolValue")
stat7.Value=date:GetAsync(key.."7"..plyr.UserId, stat7.Value)
stat7.Parent=a
stat7.Name="HT1"
local stat8=Instance.new("BoolValue")
stat8.Value=date:GetAsync(key.."8"..plyr.UserId, stat8.Value)
stat8.Parent=a
stat8.Name="H2"
local stat9=Instance.new("BoolValue")
stat9.Value=date:GetAsync(key.."9"..plyr.UserId, stat9.Value)
stat9.Parent=a
stat9.Name="H3"
local stat10=Instance.new("BoolValue")
stat10.Value=date:GetAsync(key.."10"..plyr.UserId, stat10.Value)
stat10.Parent=a
stat10.Name="H4"
local stat11=Instance.new("BoolValue")
stat11.Value=date:GetAsync(key.."11"..plyr.UserId, stat11.Value)
stat11.Parent=a
stat11.Name="H5"
local stat12=Instance.new("BoolValue")
stat12.Value=date:GetAsync(key.."12"..plyr.UserId, stat12.Value)
stat12.Parent=a
stat12.Name="T2"
local stat13=Instance.new("BoolValue")
stat13.Value=date:GetAsync(key.."13"..plyr.UserId, stat13.Value)
stat13.Parent=a
stat13.Name="F2"
local stat14=Instance.new("BoolValue")
stat14.Value=date:GetAsync(key.."14"..plyr.UserId, stat14.Value)
stat14.Parent=a
stat14.Name="H6"
local stat15=Instance.new("BoolValue")
stat15.Value=date:GetAsync(key.."15"..plyr.UserId, stat15.Value)
stat15.Parent=a
stat15.Name="F3"
local stat16=Instance.new("BoolValue")
stat16.Value=date:GetAsync(key.."16"..plyr.UserId, stat16.Value)
stat16.Parent=a
stat16.Name="T3"
local stat17=Instance.new("BoolValue")
stat17.Value=date:GetAsync(key.."17"..plyr.UserId, stat17.Value)
stat17.Parent=a
stat17.Name="H7"
local stat18=Instance.new("BoolValue")
stat18.Value=date:GetAsync(key.."18"..plyr.UserId, stat18.Value)
stat18.Parent=a
stat18.Name="H8"
local stat19=Instance.new("BoolValue")
stat19.Value=date:GetAsync(key.."19"..plyr.UserId, stat19.Value)
stat19.Parent=a
stat19.Name="H9"
local stat20=Instance.new("BoolValue")
stat20.Value=date:GetAsync(key.."20"..plyr.UserId, stat20.Value)
stat20.Parent=a
stat20.Name="HT2"
local stat21=Instance.new("BoolValue")
stat21.Value=date:GetAsync(key.."21"..plyr.UserId, stat21.Value)
stat21.Parent=a
stat21.Name="H10"
end)
game.Players.PlayerRemoving:connect(function(plyr)
local a=plyr.Hat
wait(0.1)
local stat= a.S1 -- saves all, or i wished it did
stat.Value = date:SetAsync(key.."1"..plyr.UserId, stat.Value)
local stat2= a.S2
stat2.Value = date:SetAsync(key.."2"..plyr.UserId, stat2.Value)
local stat3= a.S3
stat3.Value = date:SetAsync(key.."3"..plyr.UserId, stat3.Value)
local stat4= a.H1
stat4.Value = date:SetAsync(key.."4"..plyr.UserId, stat4.Value)
local stat5= a.F1
stat5.Value = date:SetAsync(key.."5"..plyr.UserId, stat5.Value)
local stat6= a.T1
stat6.Value = date:SetAsync(key.."6"..plyr.UserId, stat6.Value)
local stat7= a.HT1
stat7.Value = date:SetAsync(key.."7"..plyr.UserId, stat7.Value)
local stat8= a.H2
stat8.Value = date:SetAsync(key.."8"..plyr.UserId, stat8.Value)
local stat9= a.H3
stat9.Value = date:SetAsync(key.."9"..plyr.UserId, stat9.Value)
local stat10= a.H4
stat10.Value = date:SetAsync(key.."10"..plyr.UserId, stat10.Value)
local stat11= a.H5
stat11.Value = date:SetAsync(key.."11"..plyr.UserId, stat11.Value)
local stat12= a.T2
stat12.Value = date:SetAsync(key.."12"..plyr.UserId, stat12.Value)
local stat13= a.F2
stat13.Value = date:SetAsync(key.."13"..plyr.UserId, stat13.Value)
local stat14= a.H6
stat14.Value = date:SetAsync(key.."14"..plyr.UserId, stat14.Value)
local stat15= a.F3
stat15.Value = date:SetAsync(key.."15"..plyr.UserId, stat15.Value)
local stat16= a.T3
stat16.Value = date:SetAsync(key.."16"..plyr.UserId, stat16.Value)
local stat17= a.H7
stat17.Value = date:SetAsync(key.."17"..plyr.UserId, stat17.Value)
local stat18= a.H8
stat18.Value = date:SetAsync(key.."18"..plyr.UserId, stat18.Value)
local stat19= a.H9
stat19.Value = date:SetAsync(key.."19"..plyr.UserId, stat19.Value)
local stat20= a.HT2
stat20.Value = date:SetAsync(key.."20"..plyr.UserId, stat20.Value)
local stat21= a.H10
stat21.Value = date:SetAsync(key.."21"..plyr.UserId, stat21.Value)
end)
If anyone could help me out with datastores and help me fix this mess I would really appreciate thanks!

1 comment
well, i think you can save a table, but not sure idk much about ds