I’m making a crafting Gui, and I have several buttons, each called Craftingslot1, Craftingslot2, etc.
To find what number the player clicked I tried to use string.match.
for i, button in pairs(script.Parent:GetChildren()) do
print(button.Name)
if button.ClassName == "ImageButton" then
button.MouseButton1Click:Connect(function()
print(button.Name)
local button_number = string.match(button.Name, %d)
end)
end
end
However, I get the error on the line
local button_number = string.match(button.Name, %d)
and it says “expected identifier when parsing expression, got ‘%’”.
According to the dev wiki, %d takes the numbers out of the string