TextBox text bug

As of a few days ago I noticed some of the TextBox’s in my GUIs displaying their preset text as “TextBox” rather than the text I had set. They hadn’t been changed for weeks and I know this started sometime between Saturday (2nd July 2016) and Tuesday (5th July 2016) inclusively.

This seems to be an issue with using a dictionary to create the TextBox, as can be seen from the following examples:

No text bug:

local ScreenGui = Instance.new("ScreenGui", game:GetService("Players")["Vaeb"]:WaitForChild("PlayerGui"))
local TextBox = Instance.new("TextBox")
TextBox.Size = UDim2.new(0, 600, 0, 80)
TextBox.Position = UDim2.new(0.5, -300, 0.5, -40)
TextBox.BackgroundColor3 = Color3.new(0.1255, 0.1255, 0.1255)
TextBox.Text = "Any text here"
TextBox.TextColor3 = Color3.new(1, 1, 1)
TextBox.Font = "SourceSansBold"
TextBox.FontSize = "Size18"
TextBox.TextXAlignment = "Center"
TextBox.TextYAlignment = "Center"
TextBox.Parent = ScreenGui

Text bug:

local function Create(Type, Properties)
	local Obj = Instance.new(Type)
	for i,v in pairs(Properties) do
		Obj[i] = v
	end
	return Obj
end

local ScreenGui = Instance.new("ScreenGui", game:GetService("Players")["Vaeb"]:WaitForChild("PlayerGui"))
local TextBox = Create("TextBox",{
	["Size"] = UDim2.new(0, 600, 0, 80);
	["Position"] = UDim2.new(0.5, -300, 0.5, -40);
	["BackgroundColor3"] = Color3.new(0.1255, 0.1255, 0.1255);
	["Text"] = "Any text here";
	["TextColor3"] = Color3.new(1, 1, 1);
	["Font"] = "SourceSansBold";
	["FontSize"] = "Size18";
	["TextXAlignment"] = "Center";
	["TextYAlignment"] = "Center";
	["Parent"] = ScreenGui;
})

Edit: This doesn’t reproduce in studio for some reason, just when ran in real servers.

Keep in mind that using tables like you’re doing means that the keys could be set in an arbitrary order. Any one of those properties could be resetting another property’s value.

You should try something like this:

local function Create(instType, propArray)
    local inst = Instance.new(instType)
    for i = 1, #propArray do
        local propInfo = propArray[i]
        inst[propInfo.Property] = propInfo.Value
    end
end

That way, you can define properties in order, like so:

local TextBox = Create("TextBox", {
    {Property = "Name", Value = "Hello!"},
    {Property = "Text", Value = "Huh, this is some text!"}
})

While I’m not sure what property specifically is causing your issue, setting the properties in order should help mitigate the issue.

That wasn’t the point I was trying to make (the first set of example code I posted already fixes the issue).

The point is that none of the properties should override Text, never-mind changing the text to “TextBox”, no matter what order they’re in. What you posted is effectively the same as just setting the properties normally (example 1).

This doesn’t occur when ran in Studio.

To replicate the bug, create a new place and insert a script with this as its source:

local function Create(Type, Properties)
	local Obj = Instance.new(Type)
	for i,v in pairs(Properties) do
		Obj[i] = v
	end
	return Obj
end

game:GetService("Players").PlayerAdded:connect(function(Plr)
	wait(1)
	local ScreenGui = Instance.new("ScreenGui", Plr:WaitForChild("PlayerGui"))
	local TextBox = Create("TextBox",{
		["Size"] = UDim2.new(0, 600, 0, 80);
		["Position"] = UDim2.new(0.5, -300, 0.5, -40);
		["BackgroundColor3"] = Color3.new(0.1255, 0.1255, 0.1255);
		["Text"] = "Any text here";
		["TextColor3"] = Color3.new(1, 1, 1);
		["Font"] = "SourceSansBold";
		["FontSize"] = "Size18";
		["TextXAlignment"] = "Center";
		["TextYAlignment"] = "Center";
		["Parent"] = ScreenGui;
	})
end)

Then activate the place in https://www.roblox.com/develop and join it normally.