How to set a string to nil when clicking another button?

when clicking a button in my inventory i have a string attached to it that changes. When i click said button it gives it the string and when i click another button it gives it the string too but the first button i clicked also has this string still. how would i set the first buttons string to nil when i click another button?

for i, tower in pairs(towerShop) do
        
        local oldButton = container:FindFirstChild(tower.Name)
        if oldButton then
            oldButton:Destroy()
        end
        
        local newButton = container.Template:Clone()
        
        local status = getTowerStatus(tower.Name)
        
        if status == "Equipped" then
            newButton.Status.Text = "Equipped"
            
        else
            newButton.Status.Text = ""
        end
        
        if status == "Owned" or status == "Equipped" then
            newButton.Name = tower.Name
            newButton.TowerName.Text = tower.Name
            newButton.Visible = true
            newButton.Parent = container
        
            newButton.Activated:Connect(function()
                status = "Selected"
                --HERE I SET THE STRING TO SELECTED--
                for i, v in pairs(info.Display:GetChildren()) do
                    if v:IsA("ViewportFrame") then
                        v:Destroy()
                    end
                end

A string can’t be nil, it can be an empty string tho.

well yeah empty, nil same thing tbh but yeah thats what i meant

Empty string is different from nil, empty string is still a string, it just has no characters that doesn’t make it nil, if you want to check if a string is “nil” check the amount of characters and make sure the first 1 / 2 aren’t just spaces.

im trying to make the first buttons string empty whenever you click another button be cause whats happening right now it just sets it to selected and when u click another one then theyre both set to selected

Uhm?

This text will be blurred

yes im aware im just setting it to selected but how could i change that whenever i click another button?

Button.MouseButton1Click:Connect(function()
--change status...? 
end
 newButton.Activated:Connect(function()
                status = "Selected"

im doing that here…
is there some way that after i set it to selected that when i click another button it changes the first buttons string empty?

You can make a function that fires whenever the player clicks a button, and then check if the button the player pressed is the same as “newButton”. If it’s not, then set the status to: “”. The easiest way of doing this would be a loop i think

found a work around to this by making a boolvalue and setting it to true when u click it and then when you click another button its set to true and the other one is false