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

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

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

✓ Accepted answer

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.

1 comment

0

Thanks, cant believe I missed that.

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