Hi, how do I make it so that of the number of skins in a folder, 5 random ones will appear in the shop? Here is my code:
local skinsData = game.ReplicatedStorage.Skins:GetChildren()
local fiveRandomSkins = math.random(5, #skinsData)
function addSkins(data)
for i, v in pairs(data) do
local frame = createFrame(v.Name, v.Cost.Value, v, skins.Folder, "skin")
if game.Players.LocalPlayer.SkinInventory:FindFirstChild(v.Name) then
frame.Cost.Text = "Owned"
frame.Button.Image = greenTick
end
if game.Players.LocalPlayer.equippedSkin.Value == v.Name then
frame.Cost.Text = "Equipped"
frame.Button.Image = greenTick
end
frame.Button.MouseButton1Click:Connect(function()
local result = game.ReplicatedStorage.BuyItem:InvokeServer(v.Name, "skin")
if result == "bought" then
frame.Button.Image = greenTick
frame.Cost.Text = "Owned"
elseif result == "equipped" then
for _, object in pairs(skins.Folder:GetChildren()) do
if object:IsA("Frame") and object:FindFirstChild("Cost") then
if game.Players.LocalPlayer.SkinInventory:FindFirstChild(object.Name) then
object.Cost.Text = "Owned"
end
end
end
frame.Button.Image = greenTick
frame.Cost.Text = "Equipped"
end
end)
end
end
game.ReplicatedStorage.SendData.OnClientEvent:Connect(function()
addSkins(skinsData)
addTraps(trapsData)
end)