I can’t seem figure how to get the image id from this dictionary, no matter how many times I try i can’t get my head around it.
a small part of my code on a local script on the client for a GUI:
local contentsModule = rs:WaitForChild("SpinnerContents")
local contents = require(contentsModule)
local itemTypes = contents:GetItemTypes()
local function AddToInventory(ItemName, ItemImage, ItemColour)
local TemplateClone = Template:Clone()
TemplateClone.Parent = inventoryScrollingFrame
TemplateClone.ItemName.Text = ItemName
TemplateClone.Image = ItemImage
TemplateClone.ItemName.TextColor3 = ItemColour
TemplateClone.Name = ItemName
buttonConnections[#buttonConnections + 1] = TemplateClone.MouseButton1Down:Connect(function()
if player.Equipped.Value ~= TemplateClone.Name then
script.Parent.Inventory.ItemInformation.ItemImage.Image = TemplateClone.Image
game.ReplicatedStorage.SendEquipped:FireServer(TemplateClone.Name)
end
end)
end
game.ReplicatedStorage.SendEquipped.OnClientEvent:Connect(function(weps)
for i, v in pairs(weps) do
AddToInventory() -- details from dictionary here
end
end)
dictionary in replicated storage:
function contents:GetItemTypes()
local itemTypes = {
-----------------------------------
{
Rarity = {Name = "Common", Chance = 0.589, Color = Color3.fromRGB(0,85,127)};
Items = {
{Name = "Test", ImageId = --image id would be here, i have a tester value as i haven't made any yet.
{Name = "Test2", ImageId = --image id would be here, i have a tester value as i haven't made any yet.
}
};
-----------------------------------
{
Rarity = {Name = "Uncommon", Chance = 0.300, Color = Color3.fromRGB(43,125,43)};
Items = {
{Name = "Item6", ImageId = --image id would be here, i have a tester value as i haven't made any yet.
{Name = "Item7", ImageId = --image id would be here, i have a tester value as i haven't made any yet.
}
};
-----------------------------------
{
Rarity = {Name = "Rare", Chance = 0.100, Color = Color3.fromRGB(210,85,0)};
Items = {
{Name = "Item11", ImageId = --image id would be here, i have a tester value as i haven't made any yet.
{Name = "Item12", ImageId = --image id would be here, i have a tester value as i haven't made any yet.
}
};
-----------------------------------
{
Rarity = {Name = "Legendary", Chance = 0.010, Color = Color3.fromRGB(170,0,0)};
Items = {
{Name = "Test16", ImageId = --image id would be here, i have a tester value as i haven't made any yet.
{Name = "Item17", ImageId = --image id would be here, i have a tester value as i haven't made any yet.
}
};
-----------------------------------
{
Rarity = {Name = "Mythical", Chance = 0.001, Color = Color3.fromRGB(170,0,225)};
Items = {
{Name = "Item21", ImageId = --image id would be here, i have a tester value as i haven't made any yet.
}
};
-----------------------------------
};
-- Records the group the item belongs to. This can be used to retreive data on the item's group (such as it's rarity, color, etc) when we only have info for the item.
for groupIndex, group in pairs(itemTypes) do
for i, item in pairs(group.Items) do
item.GroupIndex = groupIndex
end
end
return itemTypes
end
To sum it up I want to run the function AddToInventory() but I can’t seem to get the information I need from the dictionary, and also I didn’t make this dictionary I am using a modified version of this tutorial: