Achieve
I’m simply trying to make a keybind system that goes through a table that has the keybinds needed to be pressed down for something to be triggered.
Issue
The first keybind in the keybinds table does not work and if I use the second keycode in the keybind table, it fires. I need it to require all the keybinds in the table.
Solutions
- I’ve searched the entire DevForum for post relating to this, no luck;
- I’ve rewritten the code countless times, no luck;
- I’ve tried debugging and solving this on my own, no luck.
Script
----------------[Settings]----------------
--[Toggles]--
local AllowFreeCam = true --[This allows people to use a FreeCam mode.]--
----------------[Services]----------------
local RunService = game:GetService("RunService")
local UIS = game:GetService("UserInputService")
----------------[Variables]----------------
local Equipped = false
local Tool = script.Parent
local Players = game.Players
local Characters = nil
local num = 0
--[Keybinds]--
local FreecamKeybind = {Enum.KeyCode.LeftShift, Enum.KeyCode.P}
local FixcamKeybind = {Enum.KeyCode.LeftShift, Enum.KeyCode.F}
--[Keybind Decoder]--
local function KeybindDecoder(Key,Keybind)
if UIS:IsKeyDown(Keybind[#Keybind]) then
print("Completed")
return true
end
end
UIS.InputBegan:Connect(function(KeyPressed)
if UIS:GetFocusedTextBox() == nil then
if Equipped == true then
if KeyPressed.KeyCode == Enum.KeyCode.E then
NextPlayer()
elseif KeyPressed.KeyCode == Enum.KeyCode.Q then
PreviousPlayer()
else
if KeybindDecoder(KeyPressed,FixcamKeybind) then
FixCam()
end
print("Ran")
--[[elseif KeyPressed.KeyCode == FreecamKeybind[#FreecamKeybind] then
ToggleFreecam()]]
end
end
end
end)
--[Equpped]--
script.Parent.Equipped:Connect(function()
Equipped = true
GatherPlayers()
end)
--[Unequipped]--
script.Parent.Unequipped:Connect(function()
Equipped = false
DismantlePlayers()
game.Workspace.CurrentCamera.CameraSubject = game.Players.LocalPlayer.Character.Humanoid
end)
Thank you to anyone who can help.