Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

"Attempt to concatenate field '?' (a userdata value)"?

Asked by
Benbebop 1049 Moderation Voter
5 years ago
local OfficialLevels = game.Workspace.OfficialLevels:GetChildren()


for i=1,#OfficialLevels do
    local x = script.Template:Clone()
    x.ListButton.Position = UDim2.new(1,0,(0.2 * i),0)
    x.ListImage.Position = UDim2.new(0,0,(0.2 * i),0)
    x.ListButton.Text = string.gsub(OfficialLevels[i].Name, "_", " ")
    x.ListImage.Image = "rbxgameasset://Images/" .. OfficialLevels[i].IconImage.Value
    x.ListButton.Name = OfficialLevels[i] .. "Button"
    x.ListImage.Name = OfficialLevels[i] .. "Icon"
    x.Parent = script.Parent
    print("Completed " .. x.ListButton.Name .. " and " .. x.ListImage.Name)
end 

I get this error on line ten

10: attempt to concatenate field '?' (a userdata value)

But i'm not sure what it means.

I'm trying to make a list of all the values in OfficialLevels with some of the information contained in them. I made a template to be used for each item on the list which is parented to the script.

This is a server side script.

1 answer

Log in to vote
1
Answered by 5 years ago
Edited 5 years ago

The problem is you are trying to concatenate an instance with a string.

To fix this I think all you need to do is change OfficialLevels[i] to OfficialLevels[i].Name on line 10 and 11.

0
Thanks, cant believe I missed that. Benbebop 1049 — 5y
Ad

Answer this question