How to reference this?

Hello there!
I’ve got a little problem in the script.
The problem that I want to reference a value of an IntValue that has a name of player’s UserId and simply can’t do that.

Script itself:

Instance.new("Hint",workspace).Text = ""
jump_to = 25

script.Parent.Touched:connect(function(part)
	h = part.Parent:FindFirstChild("Humanoid")
	if h then
		b = game.Players:playerFromCharacter(part.Parent)
		if b then
			b.leaderstats.Stage.Value = jump_to
			local bid = b.UserId
			game.ServerStorage.CheckpointData[bid].Value = jump_to
			h.Health = 0
		end
	end
end)

As you see, I am trying to get player’s UserId with local bid = b.UserId. And reference a value with game.ServerStorage.CheckpointData[bid].Value that is located in server storage

But it gives me an error:

And I would like to know how to reference that value because it is really needed :slight_smile:

You can try to turn UserId to string and then try to index it like that:
local bid = tostring(b.UserId)

1 Like

Make sure Instance in serverstorage is NumberValue or IntValue

1 Like

Yes, it is an IntValue. :slight_smile:

I made it so it will create IntValue with UserId and I’m too lazy to change everything back.

I guess I found how to solve the problem! I will try doing this with in pairs loop.

you have to tostring(userId) and also it’s not playerFromCharacter, its GetPlayerFromCharacter

playerFromCharacter is the deprecated version. It still works, though it’s preferred to use the latter.

1 Like

Yes, it works but I was going to write GetPlayerFromCharacter and accidently wrote playerFromCharacter.