You can write your topic however you want, but you need to answer these questions:
- What do you want to achieve? Keep it simple and clear!
I want the pair loop to break using a mousebutton1click function but the break says its not in a loop
- What is the issue? Include screenshots / videos if possible!
it errors by saying its not in a loop
- What solutions have you tried so far? Did you look for solutions on the Developer Hub?
i searched all over dev fourm but its talking about while and repeat loops but not about pair loops.
local tableofnames = {"UpKeybind","RightKeybind","LeftKeybind","DownKeybind"}
for _,button in pairs(script.Parent:GetChildren()) do
if button:IsA("TextButton") and table.find(tableofnames,button.Name) then
button.MouseButton1Click:Connect(function()
if script.Parent.ScrollingFrame.Visible == true then return end
script.Parent.ScrollingFrame.Visible = true
for _,key in pairs(Enum.KeyCode:GetEnumItems()) do -- i need to break this loop
if string.find(key.Name,"World") or key == Enum.KeyCode.Unknown then else
local clone = script.Parent.ScrollingFrame.TextButton:Clone()
clone.Name = key.Name
clone.Text = key.Name
clone.Parent = script.Parent.ScrollingFrame
clone.Visible = true
clone.MouseButton1Click:Connect(function()
button.Text = key.Name
break -- but it says this isnt in a loop
end)
end
end
end)
end
end