You can write your topic however you want, but you need to answer these questions:
I’m trying to make it so i don’t have to script each of those buttons one by one a more better way to do it but now i’m having a issue
the issue is When i click the button it print 8x and you can see why that can be a issue
for _, button in pairs(script.Parent.Parent.LeftMiddle:GetDescendants()) do
if button:IsA("TextButton") then
button.MouseEnter:Connect(function()
if button.Name == "Inventory" then
print("InventoryHover")
elseif button.Name == "Settings" then
print("SettingsHover")
elseif button.Name == "Shop" then
print("ShopHover")
end
button.MouseButton1Click:Connect(function()
if button.Name == "Inventory" then
print("Inventory")
elseif button.Name == "Settings" then
print("Settings")
elseif button.Name == "Shop" then
print("Shop")
end
end)
end)
end
end
This is most likely happening because you have the button.MouseButton1Click:Connect() inside the loop. so you connect the function as many times as the loop.
if button:IsA("TextButton") then
button.MouseEnter:Connect(function()
if button.Name == "Inventory" then
print("InventoryHover")
elseif button.Name == "Settings" then
print("SettingsHover")
elseif button.Name == "Shop" then
print("ShopHover")
end
end)
button.MouseButton1Click:Connect(function()
if button.Name == "Inventory" then
print("Inventory")
elseif button.Name == "Settings" then
print("Settings")
elseif button.Name == "Shop" then
print("Shop")
end
end)
end
end