Search code examples
textluaroblox

Lua TextLabel Text Change Script ROBLOX


I'm working on a ROBLOX game and trying to add an intermission. It should wait until the round is over then change its text to an Int countdown. Here's my script:

TeamChange = game.StarterGui.TeamChange
LobbyBar = game.StarterGui.LobbyBar

TimeWaited = 0 

TeamChange.Enabled = false
LobbyBar.TextLabel.Text = "Please Wait for Next Round!"
GameEnded = true



if GameEnded == true then
    TeamChange.Enabled = true
    repeat
        LobbyBar.TextLabel.Text = "Intermission:  " + TimeWaited + " Seconds"
        TimeWaited = TimeWaited + 1
        delay(1)
    until TimeWaited == 10
else
    LobbyBar.TextLabel.Text = "Please Wait for Next Round!"
    TeamChange.Enabled = false
end

The error pops up on this line LobbyBar.TextLabel.Text = "Intermission: " + TimeWaited + " Seconds"

Also if it's important the GUIs are childs of StarterGui and this script is in SeverScriptService.


Solution

  • The problem is that you're trying to sum text rather than concatenate it. In lua, to concatenate text, the syntax is ... So instead of "Intermission: " + TimeWaited + " Seconds", you should use "Intermission: " .. TimeWaited .. " Seconds".