Attempt to call a nil value

I have this code:

Players.PlayerAdded:Connect(function(player)
	Notification:FireAllClients("Player Join", player.Name .. " has joined the game!", "http://www.roblox.com/Thumbs/Avatar.ashx?x=150&y=150&Format=Png&username="..player.Name)
	
	wait(5)
	
	local Data = DS:GetAsync(player.UserId)
	if Data and game.Players:FindFirstChild(player.Name) then
		Data:RemoveAsync(player.UserId)
	end
end)

But I get this error:

Does anyone know why?

Can you point out which line is line 16 in your script.

1 Like

Data:RemoveAsync(player.UserId)

you must do DS:RemoveAsync(player.UserId) and not Data:RemoveAsync(player.UserId) because :RemoveAsync() is a function of a GlobalDataStore

1 Like

Thank you! I am so dumb, lol. I guess I wasn’t paying enough attention.