✓ Accepted answer
The KeyDown event returns the key that was pressed. You're checking if the key that was pressed was Shift and t. That's likes checking if 1 is 1 and 2. 1 will only ever be 1 and 2 will only ever be 2. Therefore, you have to check the values independantly.
But before I get into that then I want to address your usage of KeyDown. KeyDown is deprecated and only exists in the roblox API for compatibility; moreover, so old scripts do not break. You should use UserInputService! UIS is compatible with any and all user input, not just keys.. as well as has a much broader range of keys that can be accessed than KeyUp / KeyDown.. not to mention readability.
So, the UserInputService equivelant of KeyDown would be InputBegan. The InputBegan event returns two values; The input object, and a bool for whether or not the event was fired as a Game Processed Event(GPE). A GPE is something like chatting.. thus, a perfect way to make sure the user is not chatting whilst using this event.
Now.. you would have to have a value that would be true when shift is being pressed and false when not. So, check if the key was Shift with InputBegan to turn it on, and InputEnded to turn it off. Then, you would check if said value was true while the input was the specified key.
local plr = game.Players.LocalPlayer
local mouse = plr:GetMouse()
local uis = game:GetService('UserInputService')
local shift = false
uis.InputBegan:connect(function(input,process)
if not process then
if input.KeyCode == Enum.KeyCode.LeftShift then
shift = true;
elseif input.KeyCode == Enum.KeyCode.T and shift then
plr.Character:MoveTo(mouse.Hit.p)
end
end
end)
uis.InputEnded:connect(function(input,process)
if not process then
if input.KeyCode == Enum.KeyCode.LeftShift then
shift = false
end
end
end)
10 comments
It didn't work. I saw no errors in output, though
Worked perfectly for me in studio and in game. Is it in a loclascript in somewhere that replicates to the client?
Starterpack.
Allright.. ehmm.. Make sure you're pressing Left Shift, rather than right..
I am, I tried both. It says Shift + T in output
wat .-. Recopy code plz. You might have pasted.. something else, idk.
Nothing, just says Shift + T
Do you happen to have caps lock on?
@fireboltofdeath, are you using a computer or a laptop
He accepted it so I guess it worked..?