Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

attempt to index number with 'UserId'?

Asked by 3 years ago

Does anyone know why this is happening? I have a table that updates player values across all places. I changed it to UserId instead of Name because this way if someone changes their name it, their data will be the same. This table is for an admin system which gives them a rank.

The code:

function updateRank(Player, givenRank)
    DataStore:UpdateAsync(Key, function(rank)
        rank[Player.UserId] = givenRank
    end)
end

Help will be greatly appreciated!

0
I'm pretty sure you can't set a function's parameters to another value other than the one passed in, although I haven't tested it. PoWerofThEePg 43 — 3y
0
It worked with Player.Name ColeRandom -6 — 3y
0
Use player.Name, as that value is unique like the user id, you can't change it and no two players can have the same name. PoWerofThEePg 43 — 3y
0
I know that but it is for an admin system and if they were to change their name it would screw it up ColeRandom -6 — 3y
View all comments (2 more)
0
Oh yeah and rank is a table ColeRandom -6 — 3y
0
Also it is saved on the server and not in individuals ColeRandom -6 — 3y

1 answer

Log in to vote
0
Answered by
I_Nev 200 Moderation Voter
3 years ago
Edited by Leamir 3 years ago

Please encode Lua code in the Lua block code tag (look for the Lua icon in the editor).
function updateRank(Player, givenRank)
    DataStore:UpdateAsync(Key, rank)
        rank[Player.UserId] = givenRank
    end
end

try this, this should work i think

0
That doesn't work, UpdateAsync requires a transformFunction ColeRandom -6 — 3y
0
nvm I found the issue ColeRandom -6 — 3y
Ad

Answer this question