Basically the script is I am trying to make a main menu with compact scripting as you can see. I am wondering why I am getting an error as the title says. There weren’t any relevant answers from what I’ve looked up to my intentions so I made this post.
I made the script to make it so when I press a button such as play, it will tween the other GUI’s to go to 1.2 (Which is outside the screen) but going straight down, which is why I mentioned menu.Position because I want each UI not clicked to go straight down. How would I make an approach to make a tween access the menu.Position and make it access the table?
local ts = game:GetService("TweenService")
local ScreenGUI = script.Parent.Parent
local UItween = TweenInfo.new(2, Enum.EasingStyle.Sine, Enum.EasingDirection.Out)
local menus = {
ScreenGUI.Settings,
ScreenGUI.Play,
ScreenGUI.Credits,
ScreenGUI.Shop
}
function selectMenu(SelectedMenu)
for _, menu in pairs(menus) do
if menu == SelectedMenu then
print(SelectedMenu)
else
local UIout = ts:Create(menu, UItween, {UDim2.new(menu.Position, 0, 1.2, 0)})
UIout:Play()
end
end
end
ScreenGUI.Play.MouseButton1Click:Connect(function()
selectMenu(ScreenGUI.Play)
end)
ScreenGUI.Settings.MouseButton1Click:Connect(function()
selectMenu(ScreenGUI.Settings)
end)
ScreenGUI.Credits.MouseButton1Click:Connect(function()
selectMenu(ScreenGUI.Credits)
end)
ScreenGUI.Shop.MouseButton1Click:Connect(function()
selectMenu(ScreenGUI.Shop)
end)