Can you show your current script?
local Players = game:GetService("Players")
local player = Players.LocalPlayer
local playerUI = script.Parent
local menuUI = playerUI:WaitForChild("menuTest")
local menus = playerUI:WaitForChild("menus")
local menuList = {}
for i,menu in pairs(menus:GetChildren()) do
local menu = tostring(menu.Name)
menuList[menu] = menu
print(menuList)
end
--for i,menu in pairs(menus:GetChildren()) do
-- table.insert(menuList,menu.Name)
-- print("inserted into table")
--end
local function directButton(direction)
print("connected")
print((tostring(direction)))
local tableloc = menuList[tostring(direction)]
print(tableloc)
print(menuList[direction])
print(tableloc)
menuList[direction].Visible = true
end
local function checkForButtons(checkUI)
for i,uiObject in pairs(checkUI:GetChildren()) do
if uiObject:IsA("ImageButton") or uiObject:IsA("TextButton") then
uiObject.MouseButton1Click:Connect(function()
directButton(uiObject:GetAttribute("menuDirect"))
end)
else
checkForButtons(uiObject)
local test
end
end
end
checkForButtons(menuUI)
Can you print the first index of the menulist table
local function directButton(direction)
print("connected")
print((tostring(direction))
local tableloc = menuList[tostring(direction)]
print(tableloc)
print(menuList[direction])
print(tableloc)
for _, menu in pairs(menuList) do
print(menu)
end
menuList[direction].Visible = true
end
Try this.
print(menuList[1])
returns as nil
the same error still. attempt to index nil
Output please.
What is this attribute?
uiObject:GetAttribute(“menuDirect”)
It’s “testMenu”.
1 Like
Can I get a screenshot of the output?
for i, menu in pairs (menus:GetChildren()) do
menu.Visible = true
end
Is this the intended action of your script?
its the same output it has been for last 20 minutes lol but here you go
local Players = game:GetService("Players")
local player = Players.LocalPlayer
local playerUI = script.Parent
local menuUI = playerUI:WaitForChild("menuTest")
local menus = playerUI:WaitForChild("menus")
local menuList = {}
for i,menu in pairs(menus:GetChildren()) do
local menu = tostring(menu.Name)
menuList[menu] = menu
print(menuList)
end
--for i,menu in pairs(menus:GetChildren()) do
-- table.insert(menuList,menu.Name)
-- print("inserted into table")
--end
local function directButton(direction)
print("connected")
print((tostring(direction)))
local tableloc = menuList[tostring(direction)]
print(tableloc)
print(menuList[direction])
print(tableloc)
for _, menu in pairs(menuList) do
print(menu)
end
menuList[direction].Visible = true
end
local function checkForButtons(checkUI)
for i,uiObject in pairs(checkUI:GetChildren()) do
if uiObject:IsA("ImageButton") or uiObject:IsA("TextButton") then
uiObject.MouseButton1Click:Connect(function()
print(uiObject:GetAttribute("menuDirect"))
directButton(uiObject:GetAttribute("menuDirect"))
end)
else
checkForButtons(uiObject)
local test
end
end
end
checkForButtons(menuUI)
Think I have a solution, please stay on hold.
no I only want one specific menu, the one that matches the attribute and make that one visible
Is the attribute a string?
(Ignore)
1 Like
yeah a string is the only option that works with this
Try this
local Players = game:GetService("Players")
local player = Players.LocalPlayer
local playerUI = script.Parent
local menuUI = playerUI:WaitForChild("menuTest")
local menus = playerUI:WaitForChild("menus")
local menuList = {}
for i,menu in pairs(menus:GetChildren()) do
menuList[menu] = menu.Name
print(menuList)
end
local function directButton(direction)
print("connected")
print((tostring(direction)))
local tableloc = menuList[tostring(direction)]
print(tableloc)
print(menuList[direction])
print(tableloc)
for _, menu in pairs(menuList) do
print(menu)
if menu == tostring(direction) then
print(true)
menus:WaitForChild(menu).Visible = true
else
print(false)
end
end
end
local function checkForButtons(checkUI)
for i,uiObject in pairs(checkUI:GetChildren()) do
if uiObject:IsA("ImageButton") or uiObject:IsA("TextButton") then
uiObject.MouseButton1Click:Connect(function()
print(uiObject:GetAttribute("menuDirect"))
directButton(uiObject:GetAttribute("menuDirect"))
end)
else
checkForButtons(uiObject)
local test
end
end
end
checkForButtons(menuUI)
Make sure to show me the output as always.
local function directButton(direction)
print("connected")
print((tostring(direction)))
local tableloc = menuList[tostring(direction)]
for i, menu in pairs(menus:GetChildren) do
if menu.Name == tableloc then
--Do actions
end
end
print(tableloc)
print(menuList[direction])
print(tableloc)
for _, menu in pairs(menuList) do
print(menu)
end
menuList[direction].Visible = true
end