I’m working on this system to choose a random set of clothes for the player, and I’m getting this error:
Shirt is not a valid member of Folder "ServerStorage.Clothes.Class-D"
When it clearly is a valid member.
Here is the script:
local rep = game:GetService("ReplicatedStorage")
local ss = game:GetService("ServerStorage")
local roles = 12
rep.Remotes.Initiate.OnServerEvent:Once(function(plr)
if plr and plr.Character then
local char = plr.Character
local role = Instance.new("StringValue")
role.Name = "Role"
role.Parent = plr
role.Value = ""
local RNG = Random.new()
local c = RNG:NextInteger(1, roles)
if c == 1 then
role.Value = "Class-D"
elseif c == 2 then
role.Value = "Class-D"
elseif c == 3 then
role.Value = "Council Member"
elseif c == 4 then
role.Value = "Janitor"
elseif c == 5 then
role.Value = "Scientist"
elseif c == 6 then
role.Value = "Staff"
elseif c == 7 then
role.Value = "Guard"
elseif c == 8 then
role.Value = "Class-E"
elseif c == 9 then
role.Value = "MTF"
elseif c == 10 then
role.Value = "Chaos Insurgency"
end
if ss.Clothes:FindFirstChild(role.Value) then
local plrClothes = ss.Clothes:FindFirstChild(role.Value)
for i,v in pairs(char:GetChildren()) do
if v:IsA("Accessory") or v:IsA("Hat") then
v:Destroy()
end
end
for i,v in pairs(char:GetChildren()) do
if v:IsA("Shirt") or v:IsA("ShirtGraphic") or v:IsA("Pants") then
v:Destroy()
plrClothes.Shirt = char
plrClothes.Pants = char
rep.Remotes.InitiateComplete:FireClient()
end
end
else
warn("Failed to fetch clothes: "..role.Value)
end
wait(0.3)
end
end)
If anyone can figure out why this is happening it will be apreciated.