Text Not displaying

Hello, i have a textlabel that i want to display text and it continuously cycles through a list of sentences for my loading screen. It prints it out in the output but doesn’t change the text.

local text = game.StarterGui.LoadingScreen.Frame.Textframe.Text
local LoadAssests = { 
	"Loading Assets..."; 
	"Loading Terrain..."; 
	"Loading Game Data..."; 
	"Loading Characters...";
	"Loading User Interface...";
}

while true do
	for i,v in ipairs(LoadAssests) do
		wait(4)
		text = v
		print(v)
	end
end
2 Likes

If I’m not mistaken, if is supposed to be a loading screen for the client, you should reference PlayerGui rather than StarterGui.

I believe your code works, but your changing the StarterGui, not the playerGui.

local player = game:GetService("Players").LocalPlayer
local Textframe = player.PlayerGui:WaitForChild("LoadingScreen").Frame.Textframe

local LoadAssests = { 
	"Loading Assets..."; 
	"Loading Terrain..."; 
	"Loading Game Data..."; 
	"Loading Characters...";
	"Loading User Interface...";
}

while true do
	for i,v in ipairs(LoadAssests) do
		wait(4)
		Textframe.Text = v
		print(v)
	end
end

The above code should work and I’ll even test it myself.

Also make sure this is in a local script as you can’t reference local player from the server.

2 Likes

If you are doing it to the client only, you have to reference PlayerGui like what @Syntheix said, because inside the local player the startergui will be stored inside the PlayerGui inside the local player.

1 Like

I tried this and i referred to the player gui but it still isn’t working

1 Like

I updated it, try now.

Instead of making the text variable, make it assigned to Textframe, then set the text.

Before it didnt work, but now it did.

Would it not have to be:
local Textframe = player.PlayerGui:WaitForChild("LoadingScreen").Frame.Textframe
Because even while inside the PlayerGui, you still have to access the ScreenGui (LoadingScreen) which the “Frame” object is a descendant of.

I dont know where his ScreenGui is so I just the ScreenGUI “Frame”

Right, but in the OP he had game.StarterGui.LoadingScreen.Frame so the LoadingScreen would have to be a direct descendant of PlayerGui (assuming the path to the ScreenGui is correct originally).

Oh he did, my bad. If you edit the script it should function the exact same way. I guess I didnt see it.
I adjusted my code to match it.

The simplest solution to me is to simply make this script a local script and place it within the GUI itself. Here’s the changes that would need to be made.

--This should be a local script.
--Make this a child of LoadingScreen.
local text = script.Parent.Frame.Textframe.Text
local LoadAssests = { 
	"Loading Assets..."; 
	"Loading Terrain..."; 
	"Loading Game Data..."; 
	"Loading Characters...";
	"Loading User Interface...";
}

while true do
	for i,v in ipairs(LoadAssests) do
		wait(4)
		text = v
		print(v) --Please note, this now prints to the client and not the server, however, this probably won't affect anything.
	end
end

Why not make a string value in replicated storage? Name it status and then insert a local script into ur gui. Then you can say:

local Status = game.ReplicatedStorage.Status
local Textlabel = script.Parent.TextLabel

Status.Changed:Connect(function()
Textlabel.Text = Status.Value
end)

and then in ur current script just change the string values value.

oops looks like u might have fixed it already

also for ur while true do i recommend doing this instead

while true do
local number = math.random(1, #LoadAssets)
Status.Value = LoadAssets[number]
wait(amount of time you want to wait)
end

edit: u shuld make this stuff a server sciprt

You would actually be best having it in a Local Script inside the LoadingScreen gui because you only want that player to see it anyways. That way you could end up just deleting the GUI or the script afterwards (or whatever the OP wants to do) and you aren’t constantly running the while true do loop in the background on the server nonetheless.

1 Like

I agree actually. The script I suggested is a script I used before for players to see the same text.