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.
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.