Unable to assign property Text. string expected, got table

Hello, Im trying to make it so when the player selects something in their inventory (My own inventory not roblox one) it shows some information about that item to be presented to the player. This information is stored in a module script in ReplicatedStorage. I’ve been getting this error “Unable to assign property Text. string expected, got table” for a couple hours now and I cant seem to find a solution

Error:

The code inside the Gui:

local ReplicatedStorage = game:GetService("ReplicatedStorage")

local InvFrame = script.Parent
local EquipFrame = script.Parent.Parent.EquipFrameSection
local DescriptionLabel = EquipFrame.Description
local NameLabel = EquipFrame.Title
local EquipButton = EquipFrame.EquipUseButton

local Clicked = false

local ItemPropertiesModule = require(ReplicatedStorage.Modules.ItemProperties)
local RarityColoursModule = require(ReplicatedStorage.Modules.ItemProperties.RarityColours)

for i, v in pairs(InvFrame:GetChildren()) do
	if v:IsA("ImageButton") then
		local ItemName = ItemPropertiesModule[v.Name]
		local Description = ItemPropertiesModule[v.Name].Description
		v.MouseButton1Click:Connect(function()
			print("v", ItemName, Description)
			if Clicked == false then
				local RarityMod = ItemPropertiesModule[v.Name].Rarity
				NameLabel.TextColor3 = Color3.new(RarityColoursModule[RarityMod])
				Clicked = true
				EquipButton.Visible = true
				NameLabel.Visible = true
				DescriptionLabel.Visible = true
				NameLabel.Text = ItemName
				DescriptionLabel.Text = Description
		 	elseif Clicked == true then
				Clicked = false
				EquipButton.Visible = false
				NameLabel.Visible = false
				DescriptionLabel.Visible = false
			end
		end)
	end
end

Note: The error is happening on line 27 “NameLabel.Text = ItemName” and I expect it to also happen to line 28 “DescriptionLabel.Text = Description”

Module Script:

local Items = {
	["Egg"] = {
		["Title"] = "Mythic Egg",
		["Description"] = "t",
		["Rarity"] = "Mythic"
	},
	
	["Egg2"] = {
		["Title"] = "common egg",
		["Description"] = "not a very cool egg",
		["Rarity"] = "Commmon"
	}
}

return Items
1 Like

You are setting ItemName to be a table on this line because Egg or Egg2 is a table:

local ItemName = ItemPropertiesModule[v.Name]

Like @Alexthecreator5493 said you either want:

local ItemName = ItemPropertiesModule[v.Name].Title
--or just
local ItemName = v.Name

depending on which name you want

Oh thank you I forgot about that sorry.

Also is there a way to change the colour of the Title depending on the rarity, I’ve already created a module script for this but im unsure on how to use it.

Module Script:

local RarityColours = {
	["Common"] = Color3.new(255,255,255),
	["Uncommon"] = Color3.new(69, 205, 255),
	["Rare"] = Color3.new(60, 255, 66),
	["Legendary"] = Color3.new(255, 32, 36),
	["Mythic"] = Color3.new(162, 51, 190)
}

return RarityColours

As you can see in the script earlier on I tried:

local RarityMod = ItemPropertiesModule[v.Name].Rarity
NameLabel.TextColor3 = Color3.new(RarityColoursModule[RarityMod])

However the text just appears black for some reason.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.