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

gsub brick color value not working?

Asked by
NotSoNorm 777 Moderation Voter
8 years ago

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)
0
because it returning "Bright orange 0" XToonLinkX123 580 — 8y
0
v.BrickColor = BrickColor.new(string.sub(string.gsub(colors.Parent.CurrentColor.Value,"_"," "), 0, #tostring(colors.Parent.CurrentColor.Value))) XToonLinkX123 580 — 8y

1 answer

Log in to vote
1
Answered by 8 years ago

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)
Ad

Answer this question