Okay, so I am adding a Special Ability, you have to click Shift (48) and T to teleport where your mouse is.
local player = game:GetService("Players").LocalPlayer mouse = player:GetMouse() mouse.KeyDown:connect(function (key) if key == 48 and key == "t" then --If 48 isn't shift then sorry.. player.Character:MoveTo(player.Character:MoveTo(mouse.Hit.p)) end end)
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.
--Player local plr = game.Players.LocalPlayer --Mouse local mouse = plr:GetMouse() --UserInputService local uis = game:GetService('UserInputService') --Shift value local shift = false --InputBegan uis.InputBegan:connect(function(input,process) --Make sure they're not chatting if not process then --Check if the key was shift if input.KeyCode == Enum.KeyCode.LeftShift then --Enable shift value shift = true; --Otherwise, if it's 'T' and shift is enabled elseif input.KeyCode == Enum.KeyCode.T and shift then plr.Character:MoveTo(mouse.Hit.p) end end end) --InputEnded uis.InputEnded:connect(function(input,process) if not process then if input.KeyCode == Enum.KeyCode.LeftShift then shift = false end end end)