I am trying to do mainly 3 things

  1. Award a badge to the player if he/she does not have it
  2. Give the player a random number 1-4
  3. Save that number I think the mistake is obvious since it is my first time using the DataStoreService, anyways, the mistake is that when I try to print the value, what comes out is nil
game.Players.PlayerAdded:connect(function(Player)
local Badge=game:GetService("BadgeService")
local ID=Player.userId
local ID=(tostring(ID))
	if not Badge:UserHasBadge(ID,208585099) then
	Badge:AwardBadge(ID,208585099)
	local DataStore= game:GetService("DataStoreService"):GetDataStore(Player.Name)
	local Random=math.random(1,4)
	print(Random)
	DataStore:SetAsync(Player,Random) 
	print(DataStore:GetAsync(Player))
	else 
	local DataStore= game:GetService("DataStoreService"):GetDataStore(Player.Name)
	local RealRandom=DataStore:GetAsync(ID)
	print(RealRandom)
 	end
end)

1 comment

0

I know that this isn't data persitence, but its close.