I’m trying to create a interaction menu that when you press “F” it will open, and if you press it again it will close. I tried making a true/false variable with the “CanOpen” but once I close it, the menu won’t open.
local UIS = game:GetService("UserInputService")
local NormalSize = UDim2.new(0.844, 0, 0.195, 0)
local HoverSize = UDim2.new(0.996, 0, 0.207, 0)
local ListFrame = script.Parent:WaitForChild("HolderFrame")
local InventoryButton = ListFrame:WaitForChild("InventoryButton")
local InventoryButtonVis = UDim2.new(0.5, 0, 0.145, 0)
local InventoryButtonInvis = UDim2.new(-0.526, 0, 0.145, 0)
local PartyButton = ListFrame:WaitForChild("PartyButton")
local PartyButtonVis = UDim2.new(0.5, 0, 0.381, 0)
local PartyButtonInvis = UDim2.new(-0.526, 0, 0.381, 0)
local SettingsButton = ListFrame:WaitForChild("SettingsButton")
local SettingsButtonVis = UDim2.new(0.5, 0, 0.616, 0)
local SettingsButtonInvis = UDim2.new(-0.526, 0, 0.616, 0)
local ReportButton = ListFrame:WaitForChild("ReportButton")
local ReportButtonVis = UDim2.new(0.5, 0, 0.851, 0)
local ReportButtonInvis = UDim2.new(-0.526, 0, 0.851, 0)
local CanOpen = true
UIS.InputBegan:Connect(function(Input, Typing)
if Input.KeyCode == Enum.KeyCode.F and CanOpen == true and not Typing then
CanOpen = false
task.wait()
InventoryButton:TweenPosition(
InventoryButtonVis,
"In",
"Sine",
0.25,
false
)
task.wait(0.1)
PartyButton:TweenPosition(
PartyButtonVis,
"In",
"Sine",
0.25,
false
)
task.wait(0.1)
SettingsButton:TweenPosition(
SettingsButtonVis,
"In",
"Sine",
0.25,
false
)
task.wait(0.1)
ReportButton:TweenPosition(
ReportButtonVis,
"In",
"Sine",
0.25,
false
)
end
end)
UIS.InputBegan:Connect(function(Input, Typing)
if Input.KeyCode == Enum.KeyCode.F and CanOpen == false and not Typing then
CanOpen = true
task.wait()
InventoryButton:TweenPosition(
InventoryButtonInvis,
"In",
"Sine",
0.25,
false
)
task.wait(0.1)
PartyButton:TweenPosition(
PartyButtonInvis,
"In",
"Sine",
0.25,
false
)
task.wait(0.1)
SettingsButton:TweenPosition(
SettingsButtonInvis,
"In",
"Sine",
0.25,
false
)
task.wait(0.1)
ReportButton:TweenPosition(
ReportButtonInvis,
"In",
"Sine",
0.25,
false
)
end
end)