Userid is not a valid member of player

hello everyone

recently I’ve been on the dev forum look for this weird error for some reason its called userid is not a valid member of player any help :the script is

local DS = game:GetService(“DataStoreService”):GetDataStore(“SaveData”)
game.Players.PlayerAdded:Connect(function(plr)
wait()
local plrkey = “id_”…plr.userid
local save1 = plr.leaderstats.Strength
local save2 = plr.leaderstats.Cash

local GetSaved = DS:GetAsync(plrkey)
if GetSaved then
	save1.Value = GetSaved[1]
	save2.Value = GetSaved[2]
else
	local NumberForSaving = {save1.Value, save2.Value}
	DS:GetAsync(plrkey, NumberForSaving)
end

end)

game.Players.PlayerRemoving:Connect(function(plr)
DS:SetAsync(“id_”…plr.userid, {plr.leaderstats.Strength.Value, plr.leaderstats.Cash.Value})
end)

2 Likes

Make sure you have the right capitalisation. Try use UserId. Not Userid or userid.

5 Likes

welll i tried that but it cant be fixed

you put 3 dots. You need to put only 2.

i did and when i checked the out put it’s still a error

can you send the output it shows?

Can I see your current script?

sure here it is local DS = game:GetService(“DataStoreService”):GetDataStore(“SaveData”)
game.Players.PlayerAdded:Connect(function(plr)
wait()
local plrkey = “id_”…plr.Userid
local save1 = plr.leaderstats.Strength
local save2 = plr.leaderstats.Cash

local GetSaved = DS:GetAsync(plrkey)
if GetSaved then
	save1.Value = GetSaved[1]
	save2.Value = GetSaved[2]
else
	local NumberForSaving = {save1.Value, save2.Value}
	DS:GetAsync(plrkey, NumberForSaving)
end

end)

game.Players.PlayerRemoving:Connect(function(plr)
DS:SetAsync(“id_”…plr.userid, {plr.leaderstats.Strength.Value, plr.leaderstats.Cash.Value})
end)

local plrkey = “id_”…plr.Userid is where im having problems

You still havent even changed anything.

you need to put only 2 dots and capitalize UserId

local plrkey = “id_”..plr.UserId

You still have not capitalised UserId.

ok i found the bug thanks ill reply when its fixed

something is still wrong :face_with_raised_eyebrow:

bug

Click red error and show where it does point

yea i did here this is the part im having problems local plrkey = “id_”…plr.Userid

Try local plrkey = “id_”…plr.UserId