Hello, I am trying to make a working fridge, with viewport frames…
Problem is, when the player touches the fridge with a tool, it will instead just duplicate the tool instead of being removed and cloned into the portframe.
local Frame = script.Parent.Parent:WaitForChild("FridgeGui"):WaitForChild("Frame")
local Stored = {}
local PortOrders = {
Frame:WaitForChild("Slot1"),
Frame:WaitForChild("Slot2"),
Frame:WaitForChild("Slot3"),
Frame:WaitForChild("Slot4"),
Frame:WaitForChild("Slot5"),
Frame:WaitForChild("Slot6")
}
script.Parent.Touched:Connect(function(hit)
if hit.Parent.ClassName == "Tool" and #Stored < 6 then
table.insert(Stored, hit.Parent)
hit.Parent.Parent = game.ServerStorage:WaitForChild("StoredFridgeItems")
--
local item = hit.Parent
item:Clone().Parent = PortOrders[#Stored]
end
end)
(error on line 18. item:Clone().Parent = PortOrders[#Stored]
no errors printed in console.
explorer:

I think the problem is that you are trying to put a tool into a gui. I would probably get the tool image and put it in the gui instead of cloning the tool and putting it in the gui.
It’s a viewportframe. What I am trying to do it clone the tool into the viewport frame, and it will show up on the GUI.
You should replace this line:
item:Clone().Parent = PortOrders[#Stored]
With this line:
PortOrders[#Stored].Image = item.TextureId
In the original, you were putting the tool in the table, which just moved the image labels around in the table so that the item could be the index you wanted. With this new line of code, it will make the image of the image label the same as the image of the item. If this doesn’t work, let me know.
Viewportframes are different from image labels/image buttons.
What I am trying to do is when the player puts a tool in the fridge, it will pop up as a image in the viewport frame…
How I am trying to achieve this is putting the viewport frames in order (1 - 6), afterwards, I would clone the tool into the Viewport Frame. I would get the ordered view port frame by getting the stored amount of items in the fridge. (example: 5 items in the fridge that are stored in table.
retrieve the amount by #Stored
(returns 5). Use that as an index for the portorders table.
EDIT:
I have done a revision, I have made a model and grabbed all the baseparts and place it into the new model. Then, place that model into the viewport frame order (with index).
Everything seems to start working, and no duplications, but, the model will not show on the Frame.
What is happening:

Explorer:

New code:
local Frame = script.Parent.Parent:WaitForChild("FridgeGui"):WaitForChild("Frame")
local Stored = {}
local PortOrders = {
Frame:WaitForChild("Slot1"),
Frame:WaitForChild("Slot2"),
Frame:WaitForChild("Slot3"),
Frame:WaitForChild("Slot4"),
Frame:WaitForChild("Slot5"),
Frame:WaitForChild("Slot6")
}
script.Parent.Touched:Connect(function(hit)
if hit.Parent.ClassName == "Tool" and #Stored < 6 then
table.insert(Stored, hit.Parent)
hit.Parent.Parent = game.ServerStorage:WaitForChild("StoredFridgeItems")
--
local model = Instance.new("Model")
model.Name = hit.Parent.Name
for i,v in pairs(hit.Parent:GetChildren()) do
if (v.ClassName == "BasePart") then
v:Clone().Parent = model
end
end
model.Parent = PortOrders[#Stored]
local camera = game.Workspace.Camera:Clone()
camera.Name = "PortCamera"
PortOrders[#Stored].CurrentCamera = camera
camera.Parent = PortOrders[#Stored]
end
end)
script.Parent:WaitForChild("Proximity"):WaitForChild("Withdraw").Triggered:Connect(function(plr)
if plr then
for i,v in pairs(Stored) do
if (v.ClassName == "Tool") then
for _, tool in pairs(game.ServerStorage:WaitForChild("StoredFridgeItems"):GetChildren()) do
if (v.ClassName == "Tool") and tool.Name == v.Name then
table.remove(Stored, i)
tool.Parent = plr:WaitForChild("Backpack")
end
end
end
end
end
end)
Oh ok. I don’t really know how to help you there. Sorry I couldn’t help.