Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Can I keep track of what image button the player clicked ?

I have a GUI with six buttons. Each button represents an item that can be selected and made. I'm tried creating a number value and assigning a value whenever a button is clicked, so the game can track what was clicked by the player. I used this code inside the GUI, but it's giving me an error. What is the error and is it still possible to use a number value and assign an integer to it ?

selected = nil
guiMain = script.Parent

for _,gui in pairs(guiMain:GetChildren()) do
if gui:IsA("ImageButton") then
gui.MouseButton1Click:connect(function())
selected = gui
end
end 
end

2 comments

1

You are missing a ')' on line 8, i.e "end)".  Also you have on too many ')' on line 6.

0

BlackJPI answered your first question correctly. For your second question: Yes, it is possible to assign an Integer to a NumberValue.

1 answer

You're calling an empty function with no end on line 6. The code should run if you move a closing bracket from line 6 to line 8.

This discussion is preserved as it was. New answers, comments, and votes are closed.