I go through all “NumberValue” values saved in DataStore and then go through all sword frames to clone each frame so that its number matches the value of “NumberValue”. But I dont understand for loop logic.
Here’s what I came up with so far:
Players.PlayerAdded:Connect(function(Player)
local PlayerData = ReplicatedStorage.PlayerData:WaitForChild(Player.UserId)
local PlayerDataInventory = PlayerData.Inventory
local PlayerGui = Player.PlayerGui
local Inventory = PlayerGui:WaitForChild("Inventory").ImageLabel.Inventory
for _, v in PlayerDataInventory:GetChildren() do
if v.Value >= 0 then
for _, k in ReplicatedStorage.SwordHolders:GetChildren() do
for i = 1, v.Value do
k:Clone()
k.Parent = Inventory
k.Visible = true
end
end
end
end
end)