i have 3 rarity type caterpillars from the shop that u can buy. in the inventory what’s happening is, in the viewportframe, the models names have the correct rarity type but it only clones the common caterpillar model for every slot. so if i had a rare caterpillar, the name of the model would be “rare caterpillar” but the visual model is a common caterpillar.
code:
local caterpillarModels = {
common_caterpillar = dataFolder:FindFirstChild("common_caterpillar"),
uncommon_caterpillar = dataFolder:FindFirstChild("uncommon_caterpillar"),
rare_caterpillar = dataFolder:FindFirstChild("rare_caterpillar"),
}
function module.createSlots()
local totalval = 0
--count slots to make
for _, int in pairs(invfolder:GetChildren()) do
if int:IsA("IntValue") and int.Value > 0 then
if open == true then
for i = 1, int.Value do
local model = caterpillarModels[int.Name]
print(model.Name)
local slotclone = slotButton:Clone()
slotclone.Parent = scrollingframe
local thumbnail = slotclone.thumbnail
local cam = Instance.new("Camera")
cam.Parent = thumbnail
thumbnail.CurrentCamera = cam
if model then
print("Found model for " .. int.Name .. ": " .. model.Name)
else
print("No model found for: " .. int.Name)
end
local modelClone = model:Clone()
modelClone.Parent = thumbnail
local modelCF = modelClone:GetBoundingBox()
cam.CFrame = CFrame.new(modelCF.Position + Vector3.new(35,0,0)) * CFrame.Angles(0, math.rad(90), 0)
end
end
end
end
I’m not sure, But I’m pretty confident the issue is here.
for _, int in pairs(invfolder:GetChildren()) do--these are all the caterpillars, right?
if int:IsA("IntValue") and int.Value > 0 then
if open == true then
for i = 1, int.Value do--what is this doing, can you explain?
so ive got this InventoryFolder in each player which has intvalues. that stores how many of each item they have from the shop. im iterating thru the folder so i can work with the different intvalues. if the intValue’s value is more than 0 then the player has something, i want it to create slots; that’s if the inventory is open.
Okay, that means that the issue is with the Frame cloning at the bottom of the code.
Is the slotclone.thumbnail image the common caterpillar by default? (If you look right now, without playing the game, is the current thumbnail the common caterpillar?)
Is the slotclone an ImageButton?
if it is, you can’t assign images with the camera. You would need different images uploaded to the game.
If it is a ViewportFrame, can you confirm that all the models have different positions, so that they don’t overlap?
Huh, confusing. Okay, when you play the game, can you go into 1 of the slots for one of the incorrectly displayed caterpillars, and check that the model in there is the correct model, and that there is noting else in there?
Can you add a print(modelClone) to confirm that the clone is of the intended model?
Honestly at this point, I would assume that this isn’t a bug in the code, I would just assume that there is just something incorrectly named, or a common caterpillar in the wrong spot.
yeah its a strange one. i’ll find some similar resources to see if i can fix it. thank you so much for ur help missile, hope u have a great day mate!!!