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

Not able to edit TextBox position/size using UDim2?

Asked by 7 years ago
Edited 7 years ago

Hello, I was trying to code a Textbox being inserted, sized, and moved using a script. It gets inserted into the LocalPlayer just fine, but the position and size won't change. I am fairly new to lua, so I am not too sure if I used my UDim2 correctly (I believe it's the error)

Also, I don't get any errors in the script output.

local gui = Instance.new("ScreenGui",game.Players.LocalPlayer.PlayerGui)
local box = Instance.new("TextBox",game.Players.LocalPlayer.PlayerGui.ScreenGui)

box.Position = UDim2.new{0, 100},{0, 100}
box.Size = UDim2.new{0, 100},{0, 100}
box.Text = "Test"

1 answer

Log in to vote
0
Answered by
cabbler 1942 Moderation Voter
7 years ago

http://wiki.roblox.com/index.php?title=UDim2

First, in line 2 you should use the gui variable you already defined. Then, UDim2 arguments should be given like any other function. {0,0},{0,0} is a display style.

local gui = Instance.new("ScreenGui",game.Players.LocalPlayer.PlayerGui)
local box = Instance.new("TextBox",gui)

box.Position = UDim2.new(0, 100,0, 100)
box.Size = UDim2.new(0, 100,0, 100)
box.Text = "Test"
0
Okay, thanks for clearing it up. I thought it had to look like the actual property with the weird {} brackets. EliteJcoombs 77 — 7y
Ad

Answer this question