Text does not update when I click a button

local button = script.Parent  
local countdownDuration = 30  
local countdownText = "Free Answer in %d..."  
local endCountdownText = "Click for free answer"  

local textLabel = script.Parent.Parent.Display 
local player = game.Players.LocalPlayer
local currentStageValue = player:WaitForChild("CurrentStage")
local isCountdownInProgress = false  


local function startCountdown()
    if not isCountdownInProgress then  
        isCountdownInProgress = true  
        for i = countdownDuration, 0, -1 do
            button.Text = string.format(countdownText, i)
            wait(1)  
        end
        button.Text = endCountdownText
        textLabel.Text = currentStageValue.Value 
        isCountdownInProgress = false  
    end
end


button.MouseButton1Click:Connect(startCountdown)

when i press the button, it does not update the text of textLabel. it does not give me any errors in the output either. the value saved within the player is a stringvalue.

1 Like

can you please put some print statements throughout it, to check what is running and what isn’t?

I would recommend putting them into the following places, marked in red:
image

I can’t see a fatal flaw in the code that should stop it from working, so I’m leaning towards that the button isn’t activating correctly.

2 Likes

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.