:missing argument #1 error

I have a script that changes a gui’s text to a datastore nuber value, it gives me the error on the title

	script.Parent.Text = "level " .. tostring(experienceStore:GetAsync(player))

isn’t player an instance maybe that’s what causing the error

1 Like

U m

GetAsync has the possibility of returning back nil, you may want to encase it inside a pcall function of some sort

Also if you’re calling this on a LocalScript you can’t use DataStores that way

2 Likes

player prints out correctly. :shallow_pan_of_food:

I am using a Script. :shallow_pan_of_food:

It’s more or less the issue with you getting a player Instance then, when you should be getting a “string” (Or key) of the player you’re wanting to obtain the data from

You can’t store Instances inside DataStores, you have to reference either the Player’s UserId or a string of some sort

local Data
local success, whoops = pcall(function()
    Data = experienceStore:GetAsync(player.UserId)
end)

if Data and success then
    script.Parent.Text = "level "..Data
else
    warn(whoops)
end
1 Like

it warns nil what does that mean?

That usually means no data was found inside that Player, or some random error occurred (More or less the first)

You’d probably want to do the same with pcalls when you’re calling SetAsync as well, cause they should both be referencing the player.UserId in order to retrieve the same key

2 Likes

As aforementioned, it should be wrapped in a pcall. If it is continuously returning nil after trying the solutions with the instances, test it in-game instead of studio as DataStores error the majority of the time in studio testing.

1 Like

Yeah it’s totally that as success prints out true.

Data still returns nil even when playing the game for some reason. Despite the fact that there is no error outputed.

Oops my bad it was player.Name not jst player.