Help With Plugin UserInputService Detecting Simultaneous Keys

I am trying to make a plugin script that uses CTRL+L to create a UI that lets you type anything (thanks to inspiration from someone).

The only problem is that the UserInputService does not detect me pressing the L after holding CTRL. Why does it do this and what do I do to go around it? I’ve already ignored the GameProcessedEvent so that’s not the problem.

Here’s my code already but it apparently doesn’t work.

local UIS = game:GetService("UserInputService")
local holding = {
	L = false;
	RCTRL= false;
	LCTRL = false;
}

UIS.InputBegan:Connect(function(inp,inchat)
	if inp.KeyCode == Enum.KeyCode.L or inp.KeyCode == Enum.KeyCode.RightControl or inp.KeyCode == Enum.KeyCode.LeftControl then
		holding[inp.KeyCode == Enum.KeyCode.L and "L" or inp.KeyCode == Enum.KeyCode.RightControl and "RCTRL" or "LCTRL"] = true
	end
	if inp.KeyCode == Enum.KeyCode.L then
		warn("L DOWN")
	elseif inp.KeyCode == Enum.KeyCode.LeftControl then
		warn("CTRL DOWN")
	end
	if holding.L and (holding.RCTRL or holding.LCTRL) then
		warn("Attempting to rename")
		local Selection = SelectionService:Get()
		if #Selection >= 1 then
			rename(Selection)
		end
	end
	if inp.KeyCode == Enum.KeyCode.Return then
		entered = os.clock()+0.185
	end
end)

UIS.InputEnded:Connect(function(inp,inchat)
	if inp.KeyCode == Enum.KeyCode.L or inp.KeyCode == Enum.KeyCode.RightControl or inp.KeyCode == Enum.KeyCode.LeftControl then
		holding[inp.KeyCode == Enum.KeyCode.L and "L" or inp.KeyCode == Enum.KeyCode.RightControl and "RCTRL" or "LCTRL"] = false
	end
end)

Nevermind, I’ll just use the InputEnded to initiate the function since it seems to work fine enough.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.