Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Attempt to Index upvalue "infoName" (a string value)?

I am getting this error for line 23. Any help?

-- Item Variables
local player = game.Players.LocalPlayer
local Item1 = script.Parent.ItemHolder.TestItem
-- Value Variables
local itemName = script.Parent.ItemName
local itemPrice = script.Parent.ItemPrice
local price = 0
local itemDesc = script.Parent.ItemDesc
local itemClass = script.Parent.Class
-- Information Holder Variables
local infoName = script.Parent.ItemInfo.Name
local infoPrice = script.Parent.ItemInfo.Price
local infoDesc = script.Parent.ItemInfo.Description
local infoClass = script.Parent.ItemInfo.Item.Class
-- Connecting Info with Values
Item1.MouseEnter:connect(function(onEnter)
	itemName.Value = "Original Sword"
	price = 100
	itemPrice.Value = "$"..price
	itemDesc.Value = "The legendary starter sword, rennovated over the years to suit the best fighters' needs."
	itemClass.Value = "Common"
	wait(0.03)
	infoName.Text = itemName.Value
	infoPrice.Text = itemPrice.Value
	infoDesc.Text = itemDesc.Value
	infoClass.Text = itemClass.Value
end)

1 comment

0

I took the "$" out of the item price value, and placed it onto the text = __ line.

1 answer

✓ Accepted answer

I saw the problem. When you were defining infoName as a variable, you accessed the Name property instead of the object itself. (In case you don't know, Name is a property for EVERYTHING!!!) The easiest way is to use WaitForChild in line 11, then the code should work fine!

Here let me show you!

-- Item Variables
local player = game.Players.LocalPlayer
local Item1 = script.Parent.ItemHolder.TestItem
-- Value Variables
local itemName = script.Parent.ItemName
local itemPrice = script.Parent.ItemPrice
local price = 0
local itemDesc = script.Parent.ItemDesc
local itemClass = script.Parent.Class
-- Information Holder Variables
local infoName = script.Parent.ItemInfo:WaitForChild("Name") --HERE!!!
local infoPrice = script.Parent.ItemInfo.Price
local infoDesc = script.Parent.ItemInfo.Description
local infoClass = script.Parent.ItemInfo.Item.Class
-- Connecting Info with Values
Item1.MouseEnter:connect(function(onEnter)
    itemName.Value = "Original Sword"
    price = 100
    itemPrice.Value = "$"..price
    itemDesc.Value = "The legendary starter sword, rennovated over the years to suit the best fighters' needs."
    itemClass.Value = "Common"
    wait(0.03)
    infoName.Text = itemName.Value
    infoPrice.Text = itemPrice.Value
    infoDesc.Text = itemDesc.Value
    infoClass.Text = itemClass.Value
end)

Also, next time, DON'T ever name an object that is already mentioned in one of the object's properties. This may confuse the script and there will be chances to error!

If you have any questions, please leave a comment down below. Thank you and I hope this will help!

This discussion is preserved as it was. New answers, comments, and votes are closed.