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

attempt to index number with 'UserId'?

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!

6 comments

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.

0

It worked with Player.Name

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.

0

I know that but it is for an admin system and if they were to change their name it would screw it up

0

Oh yeah and rank is a table

0

Also it is saved on the server and not in individuals

1 answer

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

try this, this should work i think

2 comments

0

That doesn't work, UpdateAsync requires a transformFunction

0

nvm I found the issue

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