Data Stores will not load data. How to fix?
This is my code:
01 | local DataStoreService = game:GetService( "DataStoreService" ) |
02 | local PointsStore = DataStoreService:GetDataStore( "BBSystems" , "PointsValueHolder" ) |
04 | game.Players.PlayerAdded:Connect( function (Player) |
05 | local Key = "uid_" .. Player.UserId |
06 | local leaderstats = Instance.new( "Folder" ) |
07 | local Points = Instance.new( "NumberValue" ) |
08 | local Rank = Instance.new( "StringValue" ) |
10 | leaderstats.Parent = Player |
11 | leaderstats.Name = "leaderstats" |
13 | Points.Parent = leaderstats |
14 | Points.Name = "Points" |
15 | Points.Value = PointsStore:GetAsync(Key) |
17 | Rank.Parent = leaderstats |
19 | Rank.Value = Player:GetRoleInGroup( 4494167 ) |
22 | game.Players.PlayerRemoving:Connect( function (Player) |
23 | local Key = "uid_" .. Player.UserId |
24 | PointsStore:SetAsync(Key, Player.leaderstats.Points.Value) |
and for some reason It will not load the data up when the play joins (Im not sure if it saves it either)
If you could help, that would be much appreciated!