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

Problem with capturing FontType in StringValue. How would I fix this?

Currently, I am attempting to capture the FontType of a text label inside of a value, which is also inside of that textbox.

I was wondering if there's a way I can do this without error. My code is posted below, as well as a hierarchy of how the text label is in reference to the value and the script itself.

>>Textlabel
  >>Value
      >>Script 
while true do
	wait(0)
	script.Parent.Value = script.Parent.Parent.Font	
end

2 comments

0

There are many things that should be changed here. * First off, adding wait(0) has literally no use for the code. Just do wait() if you have to * You shouldn't be looping this forever. Instead, you should change the StringValue.Value every time something specific changes * You cannot make the string value equal to the font itself, I believe. I'd remake this for you if I knew what it was meant to

0

I'm attempting to create a text-editor on ROBLOX, just for the giggles. I do appreciate your input, and now that I know how to capture fonts inside of a StringValue, I can implement this a lot better.

1 answer

✓ Accepted answer

Well, to start, you're trying to set a StringValue to an Enum value. To fix this, use tostring():

script.Parent.Value=tostring(script.Parent.Parent.Font)

However, this includes the "Enum.Font." part of the text, and we probably don't want this. To get rid of it, use a string.sub() that starts at the 11th character:

script.Parent.Value=string.sub(tostring(script.Parent.Parent.Font),11)

I hope this helped!

1 comment

1

Thanks for your answer. :)

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