I’m trying to create a function that when triggered, will require everything in a table to play the function; example, my FixCam function.
Issue
The issue is that it works with both buttons separately and I need it to work only when all the buttons are pressed at the same time.
Solutions
I have no solutions for this issue.
Script
local Functions = {
["FixCam"] = {
KeybindCodes = {Enum.KeyCode.LeftShift, Enum.KeyCode.F},
Description = "This function will fix a players camera.",
Function = function()
game.Workspace.CurrentCamera:Destroy()
wait(0.05)
game.Workspace.CurrentCamera.CameraSubject = game.Players.LocalPlayer.Character.Humanoid
game.Workspace.CurrentCamera.CameraType = "Custom"
end}
}
----------------[Main Script]----------------
UIS.InputBegan:Connect(function(KeyPressed)
if UIS:GetFocusedTextBox() == nil then
if Equipped == true then
for _,Function in pairs (Functions) do
for x,KeyCode in pairs (Function.KeybindCodes) do
if KeyPressed.KeyCode == KeyCode then
print(Function)
Function.Function()
end
end
end
end
end
end)
The issue is, no matter which Keybind I hit… it triggers. I need it to figure out that both of the keybinds are being pressed at the same time. Plus, I don’t want there to have to be an order.
local UIS = game:GetService("UserInputService")
local Functions = {
["FixCam"] = {
KeybindCodes = {Enum.KeyCode.LeftShift, Enum.KeyCode.F},
Description = "This function will fix a players camera.",
Function = function()
game.Workspace.CurrentCamera:Destroy()
wait(0.05)
game.Workspace.CurrentCamera.CameraSubject = game.Players.LocalPlayer.Character.Humanoid
game.Workspace.CurrentCamera.CameraType = "Custom"
end}
}
----------------[Main Script]----------------
UIS.InputBegan:Connect(function(KeyPressed)
if UIS:GetFocusedTextBox() == nil then
for _,Function in pairs (Functions) do
local AllPressed = true
for x,KeyCode in pairs (Function.KeybindCodes) do
if not UIS:IsKeyDown(KeyCode) then
AllPressed = false
break
end
end
if AllPressed then
Function.Function()
end
end
end
end)