This is my code:
local DataStoreService = game:GetService("DataStoreService") local PointsStore = DataStoreService:GetDataStore("BBSystems", "PointsValueHolder") game.Players.PlayerAdded:Connect(function(Player) local Key = "uid_" .. Player.UserId local leaderstats = Instance.new("Folder") local Points = Instance.new("NumberValue") local Rank = Instance.new("StringValue") leaderstats.Parent = Player leaderstats.Name = "leaderstats" Points.Parent = leaderstats Points.Name = "Points" Points.Value = PointsStore:GetAsync(Key) Rank.Parent = leaderstats Rank.Name = "Rank" Rank.Value = Player:GetRoleInGroup(4494167) end) game.Players.PlayerRemoving:Connect(function(Player) local Key = "uid_" .. Player.UserId PointsStore:SetAsync(Key, Player.leaderstats.Points.Value) end)
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!
try using a pcall to get the data and set it to a variable. this always works for me
local aDataStore = game:GetService("DataStoreService"):GetDataStore("aDataStore") game.Players.PlayerAdded:Connect(function(Player) local Key = "uid_" .. Player.UserId local leaderstats = Instance.new("Folder") local Points = Instance.new("NumberValue") local Rank = Instance.new("StringValue") leaderstats.Parent = Player leaderstats.Name = "leaderstats" Points.Parent = leaderstats Points.Name = "Points" Points.Value = aDataStore:GetAsync(Key) Rank.Parent = leaderstats Rank.Name = "Rank" Rank.Value = Player:GetRoleInGroup(4494167) local player_data_points pcall(function() player_data_points = aDataStore:GetAsync(Key) end) if player_data_points ~= nil then Player.leaderstats.Points.Value = player_data_points end end) game.Players.PlayerRemoving:Connect(function(Player) local Key = "uid_" .. Player.UserId aDataStore:SetAsync(Key, Player.leaderstats.Points.Value) end)