Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How to detect if one of the button in the GUI is clicked?

Asked by 5 years ago

Goal To print something if one of the button in the GUI is clicked. Problem I don't know what I'm doing wrong, each time I click one of the button the print keep duplicating. I suppose it's because I'm firing all of them every time one is pressed, but I don't know how I should prevent that, please help. Script ```lua local function PressedColor(ColorB) ColorB.MouseButton1Click:Connect(function() print(ColorB) script.Parent.Enabled = false end) end

UIS.InputBegan:Connect(function(Input) if Input.KeyCode == Enum.KeyCode.F then script.Parent.Enabled = true PressedColor(PurpleB) PressedColor(BlackB) PressedColor(RedB) PressedColor(BlueB) PressedColor(YellowB) PressedColor(GreenB) end end)

UIS.InputEnded:Connect(function(Input) if Input.KeyCode == Enum.KeyCode.F then script.Parent.Enabled = false end end) ```

0
What are you trying to do with pressing the 'F' key? TerminusEstKuldin 40 — 5y

Answer this question