TextBox's text somehow is "TextBox" (Data involved)

Hello!

While developping I ran into this very weird problem.

For some context:

-1 When the player joins, his data loads
-2 then the Data should be written in the text of Textboxes
-3 Somehow the Text is litteraly “TextBox”

This problem is very weird as normally I would expect errors or warns but nothing happens.

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

	--add the future values
	print(Data.NickName, Data.Description)
	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)
--I wrote this because I want to see what the Output says, and weirdly, the text seems to be correct/
--By that I mean let's say (for ex:) our description is "likes cheese" The OutPut will say this:
--likes cheese is the text and the value is (supposed) likes cheese.
		TextBox.Text = Data.NickName

		


	end
end)

So I might be doing something I am not aware of. But please tell me if there’s any mistakes or even ask for the Textboxes properties.

Overall this is very weird.

Thanks for reading.

“TextBox” is the default text for a TextBox so it may be a case of your data not loading properly.

Hmm…
How could I fix this, I tried to put this in the same lines as the first PlayerAdded (all in the same script but diff groups) yet the bug still happens.

Rather than changing the text in a server script, send the data to the player using a RemoteEvent and change it using a local script.

1 Like