im trying to assign thumbnails to my slots right. i have common, uncommon and rare caterpillars which you can buy from the shop. i have intValues which show me how much commons, uncommons etc that a player has. im trying to clone my caterpillar models to the corresponding slots.
code:
function module.createSlots()
local totalval = 0
--count slots to make
for _, caterpillarValue in pairs(invfolder:GetChildren()) do
if caterpillarValue:IsA("IntValue") and caterpillarValue.Value > 0 then
totalval += caterpillarValue.Value
end
end
if open == true then
--print("caterpillar slots to make: "..totalval)
local check = 0
--make slots
for s = 1, totalval do
local slotclone = slotButton:Clone()
slotclone.Parent = scrollingframe
local thumbnail = slotclone.thumbnail
local cam = Instance.new("Camera", thumbnail)
thumbnail.CurrentCamera = cam
check += 1
end
--print("slots created: "..check)
end
end
do u have the picture of each of them? or u are tryna display a 3D model of them, if thats the case, u should learn about ViewportDisplay, its a 3D world displaying in a 2D frame
hey man,
yes im trying to display a 3d model of them. i usually know how to work with viewportframes but im trying to adapt it so if i have 5 common caterpillars and 10 uncommon caterpillars , it’ll clone the different rarity models to the slots. i only got the slots set up but i cant really get the models to clone.
are u saying u want to add the value of 5 common caterpillar and 10 uncommon and if the result is equal or greater than rare caterpillar, u want the rare one to be displayed instead?
it’ll store how many i have bought in the intvalues i have here for different rarities:
i want my different caterpillar models to show up in the slots here:
eg. if i have 10 common caterpillars, there will be 10 common caterpillar models and so on
function module.createSlots()
local totalval = 0
for i, v in pairs(scrollingframe:GetChildren()) do -- this is to clear ur inventory before readding slots
if v.ClassName == "TextButton" then -- Assuming the slotbutton is textbutton
v:Destroy()
end
end
--count slots to make
for _, caterpillarValue in pairs(invfolder:GetChildren()) do
if caterpillarValue:IsA("IntValue") and caterpillarValue.Value > 0 then
if open == true then
for i = 1, caterpillarValue.Value do
local slotclone = slotButton:Clone()
slotclone.Parent = scrollingframe
local thumbnail = slotclone.thumbnail
local cam = Instance.new("Camera")
cam.Parent = thumbnail
thumbnail.CurrentCamera = cam
local caterpillarmodel = game.ReplicatedStorage:FindFirstChild(caterpillarValue.Name) -- Locate ur caterpillar model
if caterpillarmodel then
local ClonedModel = caterpillarmodel:Clone()
local Distance = 10
ClonedModel:PivotTo(cam.CFrame + Vector3.new(0, 0, -Distance))
ClonedModel.Parent = thumbnail
end
end
end
end
end
end
carefully read the variables and locate ur own model