You can write your topic however you want, but you need to answer these questions:
What do you want to achieve? Keep it simple and clear!
Print Attributes (Wood for example)
What is the issue? Include screenshots / videos if possible!
I dont know how
What solutions have you tried so far? Did you look for solutions on the Developer Hub?
everything I could think of
After that, you should include more details if you have any. Try to make your topic as descriptive as possible, so that it’s easier for people to help you!
{Name = "False Heavenly Root", Description = "You have False Heavenly Root", Attributes = {Fire = "Fire", Wood = "Wood", Earth = "Earth", Water = "Water", Metal = "Metal"}
function RandomRootGiver()
local profile = dataManager.Profiles[player]
local falseHeavenlyRoot = profile.Data.Roots[1]
print("Name:", falseHeavenlyRoot.Name)
print("Description:", falseHeavenlyRoot.Description)
print("Attributes:")
print("Qi Gain:", falseHeavenlyRoot.QiGain)
print("Chance:", falseHeavenlyRoot.Chance)
for _, attribute in falseHeavenlyRoot do
print(attribute.Wood)
end
end
The reason it is throwing that error is probably because the “attribute” variable in the for loop does not equal anything, meaning that the for loop did not return anything when going through the table. Remember: you must use pairs() when using a for loop like that, as you need the iterator function for the for loop to work. It seems like you forgot to use the pairs() function, so you can just replace that.
Basically: use pairs()
function RandomRootGiver()
local profile = dataManager.Profiles[player]
local falseHeavenlyRoot = profile.Data.Roots[1]
print("Name:", falseHeavenlyRoot.Name)
print("Description:", falseHeavenlyRoot.Description)
print("Attributes:")
print("Qi Gain:", falseHeavenlyRoot.QiGain)
print("Chance:", falseHeavenlyRoot.Chance)
for _, attribute in pairs(falseHeavenlyRoot) do
print(attribute.Wood)
end
end
Actually, I think there’s also another thing wrong with the script
It seems like you’re only trying to print one attribute, which you don’t need a for loop for
Also, you were trying to loop through the entire falseHeavenlyRoot for the attributes instead of the attribute table inside the falseHeavenlyRoot