Attribute name contains illegal character ' ' ("Left Leg")

So today I was scripting when I got… GASP AN ERROR!!!

Attribute name contains illegal character ' ' ("Left Leg")

Wowie zowie, anyhow I honestly have no idea how to fix this error: This is my code

function module.CreateObjValue(OBJ:Instance)
	local objValue = script:FindFirstChild('Value')
	objValue.Name = OBJ.Name
	objValue.Value = OBJ
	
	local animatables = module.GetAnimatables(OBJ)
	print(animatables)
	
	
	for Title, animatable:Instance in animatables do
		print(Title,animatable.Name)
		objValue:SetAttribute(tostring(Title),false) -- errors here
	end

	return objValue
end

I print Title which as it prints is:

Left Leg

So how do I solve this problem?

1 Like

Just remove the space!

If you need to know where the space was, replace it with an underscore.

title = tostring(title)
local modifiedTitle = string.gsub(title, " ", "_")
objValue:SetAttribute(modifiedTitle, false)
2 Likes

Its always as easy as that lol. Thanks for the help!

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.