Hello, Im trying to make it so a frame’s colour is changed to a colour inside a module script. But I’m getting an error.
Error:
Script:
local Player = game.Players.LocalPlayer
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local HttpService = game:GetService("HttpService")
local ReplicatedFirst = game:GetService("ReplicatedFirst")
local InventoryGui = script.Parent
local Container = InventoryGui:WaitForChild("InventoryStorage")
local ItemProps = require(ReplicatedStorage.Modules.ItemProperties)
local RarityColours = require(ReplicatedStorage.Modules.ItemProperties.RarityColours)
local DataFolder = ReplicatedStorage.ReplicatedData:WaitForChild(Player.UserId)
DataFolder.Inventory.Changed:Connect(function(encodedData)
local dataTable = HttpService:JSONDecode(encodedData)
for ItemName, amount in pairs(dataTable) do
local ItemFrame = Container:FindFirstChild(ItemName)
if (not ItemFrame) then
ItemFrame = ReplicatedStorage.ItemFrame:Clone()
ItemFrame.Parent = Container
ItemFrame.Name = ItemName
ItemFrame.Image = ItemProps[ItemName].ImageId
local RarityItem = RarityColours[ItemFrame.Name].Rarity
ItemFrame.ColourRarity.BackgroundColor3 = (RarityColours[RarityItem])
end
ItemFrame.AmountLabel.Text = "x"..amount
if amount <= 0 then
ItemFrame:Destroy()
end
end
end)
lines that are causing the error:
local RarityItem = RarityColours[ItemFrame.Name].Rarity
ItemFrame.ColourRarity.BackgroundColor3 = (RarityColours[RarityItem])
Module script:
local RarityColours = {
["Common"] = Color3.fromRGB(255,255,255),
["Uncommon"] = Color3.fromRGB(69, 205, 255),
["Rare"] = Color3.fromRGB(60, 255, 66),
["Legendary"] = Color3.fromRGB(255, 32, 36),
["Mythic"] = Color3.fromRGB(162, 51, 190)
}
return RarityColours