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.
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()