so while trying to apply Attributes to certain store Items, trying to Apply a string type Attribute to a TextLabel's Text gives me an error.
I still haven’t fully setup the System tho
for number, Asset in Frame:GetChildren() do
if Asset:IsA("Frame") then
if Asset:GetAttribute("Price") >= 1000 then
local Div = Asset:GetAttribute("Price")/1000
Asset.Buy.Text = "R$"..Div.."K"
else
Asset.Buy.Text = "R$"..Asset:GetAttribute("Price")
end
Asset.Desc.Text = Asset:GetAttribute("Desc") -- Error Line
Asset.Buy.Activated:Connect(function()
MarketPlaceService:PromptProductPurchase(Player, Asset:GetAttribute("Asset"))
end)
end
end
The Items Attribute’s and Children:
I am currently only testing with one Frame However, not multiple,
Why am I getting this Error?
Hello! So the error “attempt to index string with ‘Text’” means that you “Desc” in Asset.Desc.Text is being read as a string value and not the instanced TextLabel “Desc”. I believe your Frame T1 is the one housing all of the attributes? If it is you could try adding…
Asset:WaitForChild("Desc").Text
This is because “Asset” in the FOR loop is every Frame that is a child of “Frame” in this case.
This is the function I made to test your code and organization and I didnt appear to have any issues with it. I added one attribute to the frame T1 called “Desc” with the value “Test” and it changed the label text to “Test”.
local function TestFunc()
for number, Asset in script.Parent:WaitForChild("Background"):GetChildren() do
if Asset:IsA("Frame") then
Asset:WaitForChild("Desc").Text = Asset:GetAttribute("Desc")
end
end
end
TestFunc()
Let me know if this doesnt fix it and I’ll keep experimenting.
I fixed the issue, I deleted the Attribute and then recreated it which Somehow fixed it, Thanks for your help @OurAuthority, thanks for trying to fix the issue