I am currently making a replica GUI of the skyBreak terminal from Welcome to the Game II. Everything iv'e done is fine so far, apart from two things.
First: this one calculation. I don't know a good way to describe it, so let me run you through it;
function Module:newLine()
local YPos
if CurrentLine then
if CurrentLine[2] then
CurrentLine[2].TextEditable = false
end
YPos = CurrentLine[1].Position.Y.Scale + 0.030
else
YPos = 0.014
end
local PathSize = (5*#_PATH)+10
local PathLabel = Instance.new("TextLabel")
PathLabel.Name = "PathLabel"
PathLabel.Parent = ConsoleHolder
PathLabel.BackgroundColor3 = Color3.fromRGB(255, 255, 255)
PathLabel.BackgroundTransparency = 1.000
PathLabel.BorderSizePixel = 0
PathLabel.Position = UDim2.new(0.0119999936, 0,YPos, 0)
PathLabel.Size = UDim2.new(0, PathSize, 0, 15)
PathLabel.Font = Enum.Font.Code
PathLabel.Text = _PATH.." >"
PathLabel.TextColor3 = Color3.fromRGB(58, 176, 86)
PathLabel.TextSize = 14.000
PathLabel.TextXAlignment = Enum.TextXAlignment.Left
local InputLabel = Instance.new("TextBox")
InputLabel.Name = "InputLabel"
InputLabel.Parent = PathLabel
InputLabel.BackgroundColor3 = Color3.fromRGB(255, 255, 255)
InputLabel.BackgroundTransparency = 1.000
InputLabel.BorderSizePixel = 0
InputLabel.Position = UDim2.new(0, (PathSize+30), 0, 0)
InputLabel.Selectable = false
InputLabel.ClearTextOnFocus = false
InputLabel.Size = UDim2.new(0, (855-PathSize), 0, 15)
InputLabel.Font = Enum.Font.Code
InputLabel.ShowNativeInput = false
InputLabel.Text = ""
InputLabel.TextColor3 = Color3.fromRGB(58, 176, 86)
InputLabel.TextSize = 14.000
InputLabel.TextXAlignment = Enum.TextXAlignment.Left
InputLabel:CaptureFocus()
CurrentLine = {PathLabel,InputLabel}
Lines = Lines + 1
if Lines > 33 then
ConsoleHolder.CanvasSize.Y.Scale = ConsoleHolder.CanvasSize.Y.Scale + 0.030
end
end
this is the newLine function. This creates a new line in the console that allows the user to enter a command. The size of PathLabel is determined by how many letters long it's text is (_PATH is the current directory, which can be any string).As you can see, i create a variable called PathSize, which calculates the X value for PathLabel.Size.
CurrentLine is the labels of the line above the one being made: {PathLabel,InputLabel}.
With the context out of the way, i can explain my issue.
I want the InputLabel to be a certain distance from the right edge of the PathLabel. My current calculation for this is:
InputLabel.Position = UDim2.new(0, (PathSize+30), 0, 0)
However, this does not hold a solid position. The longer the PathLabel, the further inside it goes.
That is No.1.
The second question is simpler.
When i go to type something into the InputLabel, it has what seems to be a line break in it, despite me specifically setting the Text property to "". When i press back space, the textbox cursor looses its green color and returns to white, allowing me to type my message correctly. Why does this happen, and how do i prevent it?
thanks in advance.
