TextBox.Text is TextBox instead of string

Hello!

While developing my game, I added a card in which the player can identify themselves, it works fine, the data is good. But when it loads this is what happens:

As you can see it’s not supposed to be like that. In the OutPut everything works fine, I printed the Data and it is what it’s supposed to be.

Now as of right now I am at school and I can only use my memory. But basically part of my Data script should be like this:

local DataStoreService = game:GetService("DataStoreService")
local DataStore1 = DataStoreService:GetDataStore("DataStore1")

game.Players.PlayerAdded:Connect(function(player)
local Data

--Getting our Data

print(Data)
--It prints our correct Data
local GUI = player.PlayerGui.PlayersCard.Frame
local NameBox = GUI.ChangeNName
local DescBox = GUI.ChangeDesc

--This is where things are weird
NameBox.Text = Data.NickName
DescBox.Text = Data.Description
print(Data.NickName.." is the Data, the text is: "..NameBox.Text) 
print(Data.Description.." is Data, the text is: "..DescBox.Text)
--It prints well. So for example the NickName is hi the output will say this:
--hi is the Data, the text is: hi
--So weirdly no errors happen and the only thing that happens is the wrong weird text.
end)

I can share the full script later but this is based off memory. It’s very weird why this is happening, normally I would expect a bug of more like an error or no text at all but weirdly the text is TextBox, yet there are no mentions or writing of TextBox. This I can confirm based on memory for many reasons.

Very weird it might be a bug or I did a dumb mistake but I don’t think a mistake I would make would have the text to be a ClassName.

Just to clarify, you are encasing your Data inside a pcall function correct? & making sure, is the TextBox’s Text already named as TextBox while in Studio/Edit Mode? If it isn’t, then you could be getting a ClassName object somewhere but you didn’t really show it inside your example script :thinking:

1 Like

It may be a dumb error of me but as I said I do not fully know since

1- Why would in studio I add the text in TextBox to be TextBox
2- I am pretty sure I did a correct pcall, maybe I didn’t.
3- The biggest thing that removes doubt of some mistakes is of just I have no reasons to have text to be TextBox.

Again might be just a dumb mistake I didn’t see, I will share the script later today.

The script would really help, as I don’t really see anything suspicious that could be changing the TextBox’s Text apart from the properly loading data

@Jackscarlett
Script:
game.Players.PlayerAdded:Connect(function(player)
local PlayerUserid = “Player_”…player.UserId

	local Data 

	local success, errormessage = pcall(function()
		Data = DataStore1:GetAsync(PlayerUserid)
	end)
 print(Data)
	local GUI = player.PlayerGui:WaitForChild("PlayersCard").Frame.NNFrame
	local GUI2 = player.PlayerGui:WaitForChild("PlayersCard").Frame
	local TextBox = GUI.ChangeNickName
	local DescBox = GUI2.ChangeDesc

	print("PLAYER JOINED")
	print(player.Name.." is crazy") --I usually write dumb stuff
	local leaderstats = player:WaitForChild("leaderstats")
	local NickName = leaderstats.NickName
	local Description = leaderstats.Description
	--add the future values
	print(NickName.Value, Description.Value, Data.NickName)
	if Data == "" or nil then
		print("There is no text")

	else
		print("THERE IS TEXT")
		print(Data.NickName, Data.Description)
		DescBox.Text = Data.Description
		print(DescBox.Text.." is the text and the value is (supposed) "..Data.Description)
		TextBox.Text = Data.NickName
		


	end
end)