Gsub not working?

trying to replace AVELO-FLAVOR with the flavor name

local SetFlavor = "Strawberry" -- for context, not actual code
local Output = Item.Output -- "AVELO-FLAVOR w/ Ice"
local NewName = Output:gsub("AVELO-FLAVOR", SetFlavor)
ObjectTouched.Parent.Name = NewName

if anyone can help it’d be appreciated

2 Likes
local SetFlavor = "Strawberry" -- for context, not actual code
local Output = Item.Output -- "AVELO-FLAVOR w/ Ice"
local NewName = string.gsub(Output, "AVELO-FLAVOR", SetFlavor)
ObjectTouched.Parent.Name = NewName

Try this.

Same result.
Still names it “AVELO-FLAVOR w/ Ice”

1 Like

no errors in the output right?

no errors are printed no, works just doesn’t name it correctly

I think you should replace “AVELO-FLAVOR” with something else. I don’t think symbols are allowed.

2 Likes
local NewName = string.gsub(tostring(Output), "AVELO-FLAVOR", tostring(SetFlavor))

try to cast it (even though SetFlavour is already a string)

yeah you might be right actually

It worked for me after changing “AVELO-FLAVOR” with “FLAVOR”. Try that.

1 Like

as you sent this i tried replacing it with AVELOFLAVOR
you’re exactly right

worked !

1 Like

No problem! I am glad I could help!

1 Like

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