so, i was making a M1 system and a ran into a weird… thing.
so, on the fourth M1, if you user is holding down the “R” key, then it will perform a special attack. however, i cant M1, as in it wont respond unless i use an auto clicker, if the “r” key is down.
if UIS:IsKeyDown(Enum.KeyCode.R) and combo == 4 then
so, is it just my keyboard? or is there a better way to do this??? i guess my question is why am i not able to M1 when the “R” key is being held down?
i dont want it do get copied so i wont send the whole thing, just the parts you need to see
UIS.InputBegan:Connect(function(input, istyping)
if istyping then return end
if input.UserInputType == Enum.UserInputType.MouseButton1 and tick() - LastTick > 0.3 and tick() - LastComboTick > 1.5 then
if tick() - LastTick > 1 then
combo = 1
end
and
local animation = Instance.new("Animation")
if UIS:IsKeyDown(Enum.KeyCode.R) and combo == 4 then
animation.AnimationId = specialanims[1]
print("special")
else
animation.AnimationId = animTable[combo]
end
i dont think there’s anything else you need to see really, but if there is, let me know.
Right before checking if UIS:IsKeyDown(Enum.KeyCode.R), try printing UserInputService:GetKeysPressed(), as that should show every key that the player is pressing at that moment in time.
*Or is the issue that it’s not reaching that part of the function because the UserInputType condition wasn’t met in the first example codeblock you posted?
the userinputtype will not respond if it is mousebutton1 and another key is being held down. i believe keys will override the mousebutton1. for example, it wont work if im walking. i want it to be able to still function even if other keys are being pressed at that moment in time.
Hmmm, I’m not super sure what could be causing that to happen unless there are other conditions inbetween the code that you included that could be preventing it from reaching the :IsKeyDown() check *(or maybe combo is not equal to 4? Try printing out the value of that before it reaches that condition).
I tested the following LocalScript code and it would print both “1” and “2” any time I was holding down the designated key on my keyboard and then pressed the left mouse button (even if I was also holding down any of the Character movement keys at the same time):
local UserInputService = game:GetService("UserInputService")
UserInputService.InputBegan:Connect(function(input)
print(input.UserInputType)
if input.UserInputType == Enum.UserInputType.MouseButton1 then
print(1)
if UserInputService:IsKeyDown(Enum.KeyCode.R) then
warn(2)
end
end
end)
this is the entire local script. (it will not work without the other script so nobody copy
local UIS = game:GetService("UserInputService")
local LastTick = 0
local LastComboTick = 0
local combo = 1
local remote = game.ReplicatedStorage.CombatEvent
local player = game.Players.LocalPlayer
local character = player.Character
local humanoid = character.Humanoid
local HRP = character.HumanoidRootPart
local prevws = humanoid.WalkSpeed
local jumpheight = humanoid.JumpPower
UIS.InputEnded:Connect(function(input, istyping)
if istyping then return end
if input.UserInputType == Enum.UserInputType.MouseButton1 and tick() - LastTick > 0.5 and tick() - LastComboTick > 1.5 then
if tick() - LastTick > 1 then
combo = 1
end
print(combo)
LastTick = tick()
local animTable = {
'rbxassetid://17512020910', --1
'rbxassetid://17512109222', --2
'rbxassetid://17501744565', --3
'rbxassetid://17501745910' -- 4
}
local specialanims = {
'rbxassetid://17511646613',
2
}
--playerdata
local player = game.Players.LocalPlayer
local character = player.Character
local humanoid = character.Humanoid
local HRP = character.HumanoidRootPart
--varient settings
--animation settings
local animation = Instance.new("Animation")
if UIS:IsKeyDown("Space") and combo == 4 then
animation.AnimationId = specialanims[1]
else
animation.AnimationId = animTable[combo]
end
local animator = humanoid:LoadAnimation(animation)
animator:Play()
remote:FireServer(player, prevws, jumpheight)
--combo settings
if combo == #animTable then
LastComboTick = tick()
combo = 1
LastTick = tick()
else
combo += 1
end
--slowing handler
humanoid.WalkSpeed = 0
humanoid.JumpPower = 0
wait(0.25)
humanoid.WalkSpeed = prevws
humanoid.JumpPower = jumpheight
end
end)
Unfortunately, I can’t know for sure if the code would be causing that issue because I haven’t been able to replicate that behavior when testing a similar setup while using my own keyboard.
With my testing, no matter if the LocalScript is listening for InputBegan or InputEnded, it’s been able to detect if the function was activated by an input type of Enum.UserInputType.MouseButton1, and if so, it was also able to check if the KeyCode defined in UserInputService:IsKeyDown() was actually being pressed down at the same time.