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:
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.
script.Parent.MouseButton1Click:Connect(function()
local UIcorner = Instance.new("UICorner", game.StarterGui)
local Numbers = string.split(script.Parent.TextBox.Text, ',')
UIcorner.CornerRadius = UDim.new(tonumber(Numbers[1]) or 0, tonumber(Numbers[2]) or 0)
end)
local frame = script.Parent;
local textBox = frame:WaitForChild("TextBox");
local textButton = frame:WaitForChild("TextButton");
local textLabel = frame:WaitForChild("TextLabel");
local UICorner = textLabel:WaitForChild("UICorner");
textButton.MouseButton1Click:Connect(function()
-- 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 = UDim.new(table.unpack(userInput)) -- set the CornerRadius
end)
script.Parent.MouseButton1Click:Connect(function()
local UIcorner = Instance.new("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 = Udim.new(newSize[1], newSize[2])
end)