Unable to do Ctrl+T with UserInputService

I’m making a system which replicates the building tools in studio to work in-game, and I’m adding all the shortcuts. Usually Ctrl+R rotates the part and Ctrl+T tilts it, but for some reason Ctrl+T won’t work with UserInputService. I’m not sure if this is a bug or if I’m doing something wrong, but when using the code below, it only prints “Ctrl+R” and not “Ctrl+T”, at first I thought it was to do with it being a game processed event or something like that, but even with it removed from the code it still doesn’t work.

local UserInputService = game:GetService("UserInputService")

UserInputService.InputBegan:Connect(function(input)
	if UserInputService:IsKeyDown(Enum.KeyCode.LeftControl) then
		if input.KeyCode == Enum.KeyCode.R then
			print("Ctrl+R")
		elseif input.KeyCode == Enum.KeyCode.T then
			print("Ctrl+T")
		end
	end
end)
1 Like

Why don’t you check if both keys are down using IsKeyDown?

if UserInputService:IsKeyDown(Enum.KeyCode.LeftControl) and uis:IsKeyDown(Enum.KeyCode.T) then
    print("Ctrl+T")
end

It is probably because Ctrl + T is a default studio-assigned keybind. Any default studio-assigned keybind will not work with UserInputService.
image

1 Like

That’s what I was thinking but so is Ctrl+R which works with UserInputService

image

Does it work in game? Or is a studio only issue?
Can you add more print statements? Something like:

local UserInputService = game:GetService("UserInputService")

UserInputService.InputBegan:Connect(function(input)
	if UserInputService:IsKeyDown(Enum.KeyCode.LeftControl) then
		print("Control is being pressed.")
	else
		print("Control is not being pressed.")
	end
	if input.KeyCode == Enum.KeyCode.T then
		print("T pressed.")
	end
end)

It should print:

"Control is being pressed."
"T pressed."

If it doesn’t and the code works in game then it’s a studio fault.

1 Like

I’ve just tried it out in-game and it worked as intended, just a weird studio bug

Interesting.

I think the bug occurs because Ctrl + T is mapped to a part movement. Try unmapping it.

I tested the code myself and in my case Ctrl + R is mapped to the rotate tool and it doesn’t work.

1 Like

It works without the studio shortcut:

image

But I still don’t understand how I can still use the other shortcuts with UserInputService, like Ctrl+R still works in-game even with the studio shortcut:

image

This kinda works but it requires you to press T before the control key

Probably because as Control is a function key so when you hold it down Roblox studio starts detecting all keystrokes and so stops actions by UserInputService. I don’t know how it works for Ctrl + R but that’s just my idea on why it doesn’t work.

1 Like

I think it’s just an anomaly with Ctrl+T specifically due to the fact it works with not only Ctrl+R but things like Ctrl+C, V, X D and G too

I suppose it is. I recommend making a bug report about it.

At least the issue is fixed.

1 Like