Combo Keys not working as intended

My code is not working as intended. I’ve assigned LeftControl to do a certain function on my Moving Heads (Strobing). Q is to change the beam width.

I want to combine them both to make a completely different function, as a test just turning the beams on.
Although while I have the script, it still fires the Strobing and Beam width changing functions.

Here’s my script.

local UIS = game:GetService("UserInputService")

UIS.InputBegan:Connect(function(input, gameProcessedEvent)
	if (input.KeyCode == Enum.KeyCode.LeftControl and UIS:IsKeyDown(Enum.KeyCode.Q)) or (input.KeyCode == Enum.KeyCode.Q and UIS:IsKeyDown(Enum.KeyCode.LeftControl)) then
		for i,v in pairs(game.Workspace.TaLights:GetChildren()) do
			v.Head.Lens.Transparency = 0
			v.Head.Beam.light.Transparency = NumberSequence.new(0)
			v.Head.Beam.SpotLight.Enabled = true
		end
	end
end)

Here’s the Q Key script:

Player = game.Players.LocalPlayer
a = script.Parent.Parent.Parent.Administrators
Administrators = {a.User1.Value,a.User2.Value,a.User3.Value,a.User4.Value,a.User5.Value,a.User6.Value,a.User7.Value,a.User8.Value,a.User9.Value,a.User10.Value}
for i,v in pairs (Administrators) do
	if Player.Name == v then
		game:GetService("UserInputService").InputBegan:Connect(function(Key,IsTyping)
			if IsTyping then return end
			if Key.KeyCode == Enum.KeyCode.Q then
				game.Workspace.Technica.Lamp.Beam.ZoomIn1:InvokeServer()
			end
		end)
	end
end

LeftControl Script (This Key activates a function and let’s it activated until the key is released"

local uis=game:GetService("UserInputService");
Player = game.Players.LocalPlayer
a = script.Parent.Parent.Parent.Administrators
Administrators = {a.User1.Value,a.User2.Value,a.User3.Value,a.User4.Value,a.User5.Value,a.User6.Value,a.User7.Value,a.User8.Value,a.User9.Value,a.User10.Value}
local HoldLCTRL = Enum.KeyCode.LeftControl
for i,v in pairs (Administrators) do
	if Player.Name == v then
		uis.InputBegan:connect(function(input,IsTyping)
			if IsTyping then return end
			if input.KeyCode == Enum.KeyCode.LeftControl then
				game.Workspace.Technica.Hold.StrobeOn:InvokeServer()
			end
		end)
		uis.InputEnded:connect(function(input,IsTyping)
			if IsTyping then return end
			if input.KeyCode == Enum.KeyCode.LeftControl then
				game.Workspace.Technica.Hold.StrobeOff:InvokeServer()
			end
		end)
	end
end

Any way how to fix the Comboing? If something is not clear, I’ll re-explain.

2 Likes

Hello. While one key is pressed and a new one is added, InputChanged is fired rather that InputBegan. Please switch to that. Hope this helps. :slightly_smiling_face:

2 Likes

I’ll try in a second, bare with me for a moment.

Sadly does not work :frowning_face_with_open_mouth:
I changed it from InputBegan to InputChanged and it still is firing the other 2 RemoteEvents (functions basically).
Output is not throwing any errors.

Oh, so you do not want the other events to fire? In that case, you can add a

if UIS:IsKeyDown(Enum.KeyCode.Q) then return end

in your LeftShift Connection and a

if UIS:IsKeyDown(Enum.KeyCode.LeftShift) then return end

in tour Q handling script.