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

Argument 2 missing or nil? Attempt to make Datastore SetAsync function

Hey all,

I'm getting the error "Argument 2 missing or nil" when trying to SetAsync() a datastore, I'm not sure why this is happening since all the arguments print out, so it must be in the way I'm trying to store these values.

The setAsync() Function is as follows:

local function setAsync(player, gamepass, name)
	print(player)
	print(gamepass)
	print(name)
			local success, err = pcall(function()
				gamepassDataStore:SetAsync(player.UserId.."-"..gamepass, game.Players[player.Name].data.name.Value)
			end)
	if success then
		print(success)
			else 
			print(err)
			end
		end

All of the arguments print as shown below: Stedaa Dominus IsDominusHatEnabled This is the way the function is called:

setAsync(player, "Dominus", "IsDominusHatEnabled")

An example of what I'm trying to achieve would be something like this specific to the gamepass:

gamepassDataStore:SetAsync(player.UserId.."-Dominus", game.Players[player.Name].data.IsDominusHatEnabled.Value)

Thank you for your much appreciated help!

2 comments

0

The "argument 2 missing or nil" is an error with your gamepassDataStore:SetAsync. Try printing game.Players[player.Name].data.name.Value and see if it's nil

0

It returns nil, however I know the BoolValue does exist so I'm not sure why that is happening, any ideas?

1 answer

Fixed it, had to put brackets beside [name] like

game.Players[player.Name].data[name].Value

Thanks for everyones help

2 comments

0

Why couldn't you do player.data[name].Value

0

It would say player is nil for whatever reason, not too sure but it works so I'm not questioning it

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