How to make text = the value of a property?

Hi there!

I have an issue trying to make: textbutton clicked, check text value of a textbox, and put it in a UIcorner CornerRadius. Except, i get this error:


Its very confusing. I am not very good at scripting and would not know how to script this correctly. Heres the script:

	local UIcorner ="UICorner",game.StarterGui)  
	UIcorner.CornerRadius = script.Parent.TextBox.Text

Text is a string value not an int value.

Instead try this:

	local UIcorner ="UICorner",game.StarterGui)  
	UIcorner.CornerRadius = tonumber(script.Parent.TextBox.Text)

To create a new UDim2 (a property in many GUI objects which looks like {0,0,0,0}) value using a string (text), you’ll have to slice the string up a bit.

It looks like this thread has the same question and provides an answer that might work for you:

That helps, yet i have no idea how i would make this, in my case.

Ive tried scripting something like it, yet its failed.

Simply converting the string to a number wouldn’t work here unfortunately, as UIcorner.CornerRadius is a UDim. It has both scale and an offset, and a string like “{0,0}” cannot be converted into an integer. String manipulation will be necessary.


Yea this did not work for me, i didnt get an error in the output, though, for some reason.

It comes out as value: 0,0 so this does not work, thanks for trying though.

What’s exactly in your text? If it’s just a number then you can do what @kylerzong did.

something like 0, 52 for example.

use the function “tonumber”. This parses the string.

See this article for more info:

Try doing this
And put that inside the udim (I think you have to use unpack(splits) btw)

So how would i write all of this out, because im a bit confused.

	local UIcorner ="UICorner", game.StarterGui)
	local Numbers = string.split(script.Parent.TextBox.Text, ',')
	UIcorner.CornerRadius =[1]) or 0, tonumber(Numbers[2]) or 0)
1 Like

I’ve prepared a basic test place to demonstrate my solution:

StringSliceUICorner.rbxl (41.5 KB)

local frame = script.Parent;
local textBox = frame:WaitForChild("TextBox");
local textButton = frame:WaitForChild("TextButton");
local textLabel = frame:WaitForChild("TextLabel");
local UICorner = textLabel:WaitForChild("UICorner");

	-- this should work as long as the string you enter is in the format of 0,0
	local userInput =  string.split(textBox.Text, ",") -- create a new table by slicing up the string where there is a ,
	UICorner.CornerRadius = -- set the CornerRadius

Hope this helps!

	local UIcorner ="UICorner",game.StarterGui) 
        local newSize = script.Parent.TextBox.Text:split(",")
--you can use unpack(newSize) but the user might type more than 1 comma.
	UIcorner.CornerRadius =[1], newSize[2])

Well I guess I didn’t have to write this

Perfect! Exactly what i needed! Thank you so much for all the help.

Thanks anyway, i appreciate you trying to help me, this did take me 2 hours to figure out, now.

I already have a solution, but,thank you anyway, i appreciate you trying to help me.

(Check my message, too. The comment explains a possible error) also TEXT:split() works too, and unpack(TABLE) too.

print( defaults its two parameters to 0.

string.split()'s second parameter defaults to a string containing a single comma.

local s = "1,2,3"
print(table.concat(string.split(s))) --123
1 Like