How to find the part with the same name as the skin value in the leaderstats

local findpart = game.ReplicatedStorage.folder:FindFirstChild(player.leaderstats.skin.Value)

The script format I wrote is like this.
But it’s not right because if write it like this, script is find the skin value.
I want to know how to make a script to find a part that has the same name as skin value Please help me!!

-- Assuming you have these variables set up:
local player = game.Players.LocalPlayer -- Change to the specific player you're interested in
local skinValue = player.leaderstats.skin.Value -- The value you want to match
local folder = game.ReplicatedStorage.folder -- The folder containing the parts

for _, part in pairs(folder:GetDescendants()) do
    if part:IsA("BasePart") and part.Name == skinValue then
        -- You found a part with the same name as the skin value
        -- Do something with the part here
        print("Found part with name:", skinValue)
        print("Part's position:", part.Position)
    end
end

^:

  1. skinValue is set to the skin leaderstat value of the player you’re interested in.
  2. You iterate through the descendants of the `folder’ (assuming you have one).
  3. For each descendant, you check if it’s a BasePart (a part that has a name) and if its name matches the skinValue.
  4. If a matching part is found, you can perform actions of the part.

Happy to help! Please message me if you have questions or need anything else.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.