Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

user_ is not a valid member of DataStore?

So I have this points script and it gives me this error every time i try it : 22:22:07.007 - user_33666287 is not a valid member of GlobalDataStore 22:22:07.008 - Script 'Players.Player.PlayerGui.CoinGui.LocalScript', Line 3 Code:

local player = game:GetService("Players").LocalPlayer 
repeat wait() until player
local points = game:GetService("DataStoreService"):GetDataStore("Points")["user_"..player.userId]
local username = "user_"..player.userId
local text = script.Parent.TextLabel

if GlobalDataStore:GetAsync(username) == 0 or nil then 
	DataStore:UpdateAsync(username, function(add)
   				newValue = 50
    end) 
end

if username == "user_33666287" then 
	points = 100000 
end

text.Changed:connect(function()
  	text.Text = "Coins : ".. points
end) 

1 answer

✓ Accepted answer

There's a lot of errors going on here. Please look at this fix I have here. I can explain any changes I made, so please do ask.

for _, player in ipairs(game.Players:GetPlayers()) do
  local username = "user_"..player.userId
  local ds = game:GetService("DataStoreService"):GetDataStore("Points")
  local points = ds:GetAsync(username)

  local text = player.PlayerGui.CoinGui.TextLabel

  if points == 0 or points == nil then
    ds:UpdateAsync(username, function(add)
      return 50
    end)
  end

  if username == "user_33666287" then
    ds:UpdateAsync(username, function(add)
      return 100000
    end)
  end
  
  local function update() 
    text.Text = "Coins : ".. ds:GetAsync(username)
  end
	
  ds:OnUpdate(username,update)
  update()
end

This discussion is preserved as it was. New answers, comments, and votes are closed.