Im making a restaurant menu tool and it has 2 pages that has a nextpage button. The problem is that when i equip a tool the tool dissapears, how to refer to the tool? This is my script
local player = game.Players.LocalPlayer
script.Parent.MouseButton1Click:Connect(function()
player.Backpack.Menu.Menu1.Visible = true
player.Backpack.Menu.Menu2.Visible = false
player.Backpack.Menu.Visible = false
player.Backpack.Menu.leftPage.Visible = true
end)
actually you dont have to manually enable visible you can simply do that
local player = game.Players.LocalPlayer
script.Parent.MouseButton1Click:Connect(function()
player.Backpack.Menu.Enabled = true --- will enabled the GUI it should be Disabled first and everything in the GUI frame should be visbible = true then u can enable the Menu
end)
You can just store the tool in a variable so you don’t have to access it everytime
local player = game.Players.LocalPlayer
local menu = game.Players.LocalPlayer.Backpack:WaitForChild("Menu")
script.Parent.MouseButton1Click:Connect(function()
menu.Enabled = false -- idea from @MrchipsMa
end)
Or you can use :FindFirstChild() to find the tool whether it’s in the backpack or the character.
local player = game.Players.LocalPlayer
script.Parent.MouseButton1Click:Connect(function()
local menu = player.Backpack:FindFirstChild("Menu") or player.Character.Menu
menu.Enabled = false
end)