VulkSerity
(SplootingSquirrel)
July 24, 2023, 3:08pm
#1
Hey devforum! I’m trying to make a tycoon and I’m running into a bit of a problem. I’m trying to make it so above a button there’s some text and that says the name of the item they are purchasing and the cost, but it keeps saying
Heres my script
Button.BillboardGui.TextLabel.Text = getItem(Button:GetAttribute('ItemId')).Name.." - "..Item:GetAttribute('Cost')
There’s also Id’s inside of the buttons and Items, and another tycoon in replicated storage.
2 Likes
Deciq_z
(Jaafar)
July 24, 2023, 3:10pm
#2
You can create a new attribute to the button and call it ItemName.
or you can use an algorithm like this, give me a moment ^
1 Like
Basically your getItem
function returned nil. Try looking into it.
1 Like
Deciq_z
(Jaafar)
July 24, 2023, 3:13pm
#4
local itemNames = {
[ITEM_ID] = "ITEM_NAME"
}
local function GetItemName(itemID)
return itemNames[itemID]
end
Button.BillboardGui.TextLabel.Text = GetItemName(Button:GetAttribute('ItemId'))
1 Like
VulkSerity
(SplootingSquirrel)
July 24, 2023, 3:16pm
#5
Would I have to put all the “item names” into itemNames?
VulkSerity
(SplootingSquirrel)
July 24, 2023, 3:17pm
#6
Also here is my getItem function
local function getItem(itemId)
for _, Item in Items:GetChildren() do
if Item:GetAttribute('Id') == itemId then
return Item
end
end
end
I don’t really see anything wrong with it
It’s weird how you use two attributes for similar data? That is, why do you use “ItemId” and “Id” for representing item id?
VulkSerity
(SplootingSquirrel)
July 24, 2023, 3:20pm
#8
I figured it out, there was something wrong with my getItem
function
system
(system)
Closed
August 7, 2023, 3:21pm
#9
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.