Once a Button is pressed, until its unselected, I don't want any other button to toggle on

I have this system where if you press a button a viewport Frame will show the pressed button spinning in a circle.

The issue I begin to get is that a multitude of buttons can be pressed, but I only want a single one active one at a time. How would I fix this?

GUIs.MouseButton1Click:Connect(function()
            for _, ViewPortCoins: Model in pairs(PlayerGui.ScreenGui.ViewportFrame:GetChildren()) do
                if not string.find(ViewPortCoins.Name, GUIs.Name) then
                    continue 
                end  
                    for _, CoinMakeUp in pairs(ViewPortCoins:GetDescendants()) do                
                    if not CoinMakeUp:IsA("Part") or CoinMakeUp:IsA("Decal") then
                        continue 
                    end
                            if Debounce == true then return end    
                            Debounce = true
                            PressedScript = not PressedScript
                            
                            if PressedScript then
                                CoinMakeUp.Transparency = 0
                                PlayerGui.ScreenGui.CharacterName.Text = GUIs.Name
                            else
                                CoinMakeUp.Transparency = 1
                                
                                PlayerGui.ScreenGui.CharacterName.Text = "[Insert Name Here]"
                            end
            

                            task.delay(1, function()
                                Debounce = false
                            end)
                            
                        end
                    end    
                end)

My weird variable naming and terrible nesting habit when making a script at a deadline might be some room for confusion, so Ill explain coinmakeup quickly, inside of the viewport frames there are a multitude of models, im just seeing which one the character clicked and changing the transparency so they can be seen.

This current psuedo solution doesn’t do me too much good because of the PressedScript changing to not pressedscript no matter what button is pressed. Overall I just want to restrict only a singular Coin to be active at a time.

1 Like