Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Text in TextLabel is not changing, how do I fix it?

I'm completely confused on why my script will not work. I've tried changing the variables, but it just won't work.

wait()
local l = game.Players.LocalPlayer:WaitForChild("leaderstats").Level
local t = game.Players.LocalPlayer:WaitForChild("PlayerGui").Level.LevelName.Text
script.Level1:Play()
l:GetPropertyChangedSignal("Value"):Connect(function()
	
	        	if l.Value == 2 then
	            	script.Level1:Stop()
			script.Level2:Play()
			t = "Level 2"
		
			else if l.Value == 3 then
           		script.Level2:Stop()
			script.Level3:Play()
			t = "Level 3"
			
			end

        end
 end)

This LocalScript that has this code is in StarterPlayerScripts. In this code, I'm confused about the text changing, not the sound playing/stopping.

1 answer

✓ Accepted answer

On the third line you are defining the variable wrong, you are defining text of the label, but you don't do that, instead define the text label and then do t.Text = "Blablabla". Just like you have done with the value. Another issue is that if it is local script then when you will play the game you will most likely have an error that you tried to index nil, because the script ran before they loaded, for that, use WaitForChild()

1 comment

0

Ah, that makes sense now. Thanks!

This discussion is preserved as it was. New answers, comments, and votes are closed.