Hello, I have a settinggui that is supposed to set a keybind. First, you must open up the gui, and click the parent of the script (a button). The only problem is the script is still setting the keybind even after it finished asking the player for a keybind.
local UIS = game:GetService("UserInputService")
local canChange = false
script.Parent.MouseButton1Click:Connect(function()
script.Parent.Parent.Parent.Popup.Visible = true
UIS.InputBegan:Connect(function(input, gpe)
if canChange then
if input.UserInputType == Enum.UserInputType.Keyboard then
script.Parent.Text = tostring(input.KeyCode)
elseif input.UserInputType ~= Enum.UserInputType.MouseMovement or Enum.UserInputType.MouseWheel then
script.Parent.Text = tostring(input.UserInputType)
end
end
script.Parent.Parent.Parent.Popup.Visible = false
canChange = false
end)
end)
if script.Parent.Parent.Parent.Popup.Visible then
canChange = true
end
Not sure if this might help, but this is the structure of the GUIs
The popup that should allow the player to change the keybind is named ‘Popup’ in this structure.
local UIS = game:GetService("UserInputService")
script.Parent.MouseButton1Click:Connect(function()
script.Parent.Parent.Parent.Popup.Visible = true
UIS.InputBegan:Connect(function(input, gpe)
if script.Parent.Parent.Parent.Popup.Visible then
if input.UserInputType == Enum.UserInputType.Keyboard then
script.Parent.Text = tostring(input.KeyCode)
elseif input.UserInputType ~= Enum.UserInputType.MouseMovement or Enum.UserInputType.MouseWheel then
script.Parent.Text = tostring(input.UserInputType)
end
end
script.Parent.Parent.Parent.Popup.Visible = false
end)
end)