Argument 1 missing or nil Error

Hey scripting community, I’ve looked through a lot of online resources and still have not found out how to check if a missing or nil value is equal or not equal to nil. Here is my code:

It looks like it doesn’t see your “plr” variable. Did you mean to use “player”? If not, can I see what your “plr” variable stores?

Oh, plr is defined in a variable above that block of code. Here it is:

This is also the datastore script at the bottom of the server script service script:

GetAsync takes in a player key, not the actual player object. It should be a string

1 Like

I think it is because you are storing your keys as players and not strings. Take a look here:

The key has to be a string. I don’ think you can store the player itself in the datastore as a key.

The server does not have a local player, so game.Players.LocalPlayer results in nil.
Passing this to TrailStore:GetAsync will thus raise the mentioned error.
Try replacing plr with player, and possibly to something like tostring(player.UserId) while you’re at it.

This is my new code after modifying it a bit. I took your advice and replaced every plr with player, but the problem is that the pcall in the datastore cannot accept player as a parameter, and I don’t know why. I have provided a picture of my code below. Thanks!

These 2 pages contain how the functions work, and they say that you need a string as the first argument.
Try replacing player with tostring(player.UserId)