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

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

Asked by 7 years ago

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
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 iamnoamesa 674 — 7y
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. TheRings0fSaturn 28 — 7y

1 answer

Log in to vote
0
Answered by 7 years ago

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
Thanks for your answer. :) TheRings0fSaturn 28 — 7y
Ad

Answer this question