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

Is it posible to specify a value with player.Name and code the code to check for username in value??

Hi, is it possible to code it so that the code can check the value of a string value using player.Name in the code? Not player.Name in the value, but having a players username in value and using player.Name to specify a part if there are a lot of players? I know this is a weird question and hopefully I explained my question right.

2 comments

0

So is it like you have a value, that is the same as the players name?

0

yes.

1 answer

✓ Accepted answer

Here is the code you are needing:

local ValueStorage = game.ServerStorage.PlayerValues -- this is were the values are stored, change this to were they are.

local Player = PlayerHere -- This is not needed if in a function such as playeradded that returns the player.

local Value = ValueStorage:FindFirstChild(Player.Name) -- Gets the value from the players name
print(Value.Value) -- prints the value.

ValueStorage is where all the values are parented to, in this example it's a folder called PlayerValues in serverStorage. It then states what the player is. It then will find the first value with the players name, and set it to Value. Finally, it will print the value off that.

If the value off a value is a players name, such as a value named "PlayerName" having a value off the name, the code will be this:

local ValueStorage = game.ServerStorage.PlayerValues -- this is were the values are stored, change this to were they are.

local Player = PlayerHere -- This is not needed if in a function such as playeradded that returns the player.

local value -- sets this as the value later in the code.

for i, Value in pairs(ValueStorage:GetChildren()) do
	if Value.Value == Player.Name then
		value = Value
		break
	end
end

This will simply loop through every value until it gets the one it wants. It then sets the local value to it.

1 comment

0

Thank you for explaining it this helps me a lot

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