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

gsub brick color value not working?

So I'm trying to sub out all the '_'s for spaces, It doesn't seem to be working, And example of what the value could be is, Bright_orange.

colors.Parent.CurrentColor.Changed:connect(function(Value)
	local parts = game.Workspace.BeginHolder.BeginModel:GetChildren()
	for i,v in pairs (parts) do
		v.BrickColor = BrickColor.new(string.gsub(colors.Parent.CurrentColor.Value,"_"," "))
	end
end)

2 comments

0

because it returning "Bright orange 0"

0

v.BrickColor = BrickColor.new(string.sub(string.gsub(colors.Parent.CurrentColor.Value,"_"," "), 0, #tostring(colors.Parent.CurrentColor.Value)))

1 answer

✓ Accepted answer

The reason it is happening is because it is returning "Bright orangle 0" so this would be a proper fix:


colors.Parent.CurrentColor.Changed:connect(function(Value)
    local parts = game.Workspace.BeginHolder.BeginModel:GetChildren()
    for i,v in pairs (parts) do
        v.BrickColor = BrickColor.new(string.sub(string.gsub(colors.Parent.CurrentColor.Value,"_"," "), 0, #tostring(colors.Parent.CurrentColor.Value)))
    end
end)

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