This for loop is running too many times. (It prints ‘Hey’ x15, but clones my items 5 times each and places them within the char). How would I get around this? Using break or return works, but doesn’t allow for other pieces of my code to properly function.
for i, v in pairs(jobList:GetChildren()) do
if v:IsA("TextButton") then
selectBtn.MouseButton1Click:Connect(function()
local jobConfig = v:FindFirstChild("JobConfig")
local char = plr.Character
for i, n in pairs(game.ReplicatedStorage.CharacterClothes:GetChildren()) do
if n.Name == currentSelectedJob.Value then
for i, x in pairs(n:GetChildren()) do
if char:FindFirstChild(x.Name) then
char:FindFirstChild(x.Name):Destroy()
end
local jobClothes = x:Clone()
jobClothes.Parent = char
print("Hey")
end
plr.PlayerGui.JobSelectionMenu.Enabled = false
end
end
end)
end
end