Why do new players spawn in with random amounts of points instead of 0?

local DatastoreService = game:GetService("DataStoreService")
local sireneSave = DatastoreService:GetDataStore("sirene855648556")
local MarketplaceService = game:GetService("MarketplaceService")

	local leaderstats = Instance.new("Folder")
	leaderstats.Parent = player
	leaderstats.Name = "leaderstats"
	local points = Instance.new("IntValue")
	points.Name = "Points"
	points.Parent = leaderstats
	points.Value = sireneSave:GetAsync(player.UserId)
	local rank = Instance.new("StringValue")
	rank.Name = "Rank"
	rank.Parent = leaderstats
	rank.Value = player:GetRoleInGroup(4169729, player)
	if MarketplaceService:UserOwnsGamePassAsync(player.UserId, 8755524) then
		if player:GetRankInGroup(4169729) >= 5 then
			while true do
				player.leaderstats.Points.Value = player.leaderstats.Points.Value + 1
				sireneSave:SetAsync(player.UserId, player.leaderstats.Points.Value)
	while true do
		player.leaderstats.Points.Value = player.leaderstats.Points.Value + 1
		sireneSave:SetAsync(player, player.leaderstats.Points.Value)

It is because you are using DataStoreService.
The random numbers are actually the numbers you have before you leave your recent game.

That means, you are saving your recent progress.
You are loading your save, not a random number.

This might be happening because the new player does not have any data, and you’re setting the value to their data. Try doing something like this:

points.Value = sireneSave:GetAsync("Player_" .. player.UserId) or 0 --"0" is the default value

Also, if I recall correctly, you would have to do "Player_" .. player.UserId instead of just player.UserId when getting data and such.

he is asking small brain question
why is new player spawn with random numbers
which means he is asking like he doesnt know lua existed.
he did :GetAsync() btw
so the question is sane but you know
points.Value = sireneSave:GetAsync(player.UserId)

I am aware that he called GetAsync().

1 Like

omg thank you i just realized you solved one of my threads problem about default numbers!!!

You should but anything about DataStore in a pcall.