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

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

Asked by 8 years ago

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
1
You are missing a ')' on line 8, i.e "end)".  Also you have on too many ')' on line 6. BlackJPI 2658 — 8y
0
BlackJPI answered your first question correctly. For your second question: Yes, it is possible to assign an Integer to a NumberValue. nilVector 812 — 8y

1 answer

Log in to vote
0
Answered by
P100D 590 Moderation Voter
8 years ago

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.

Ad

Answer this question