Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

why MouseButton1 and UserInputType not working?

Asked by 3 years ago
Edited 3 years ago

It printed Q in the output, but it didn't print "Combo"

elseif input.KeyCode == Enum.KeyCode.Q then                
        print("Q")
        module.Punch(player)
        if input.UserInputType == Enum.UserInputType.MouseButton1 then
                print("Couter")
                module.Combo(player)

        end
0
It's because it runs only one time, it can't be Q and the mouse button at the same time. User#32819 0 — 3y
0
is there a way to make a combo with Q and mouse button thinhs11 -2 — 3y
0
I guess you could have two .InputBegan events each for one input and use tick() to detect if they have been pressed one after the another. User#32819 0 — 3y
0
ill try that thinhs11 -2 — 3y
View all comments (4 more)
0
it still doesnt work thinhs11 -2 — 3y
0
You CANNOT put the check for the mousebuttom input under the Q input, because as I said, .InputBegan is called one time, with only ONE input. Try putting it as another elseif after the Q check.  User#32819 0 — 3y
0
I updated, but it still doesnt work. Canyou give me an exmaple thinhs11 -2 — 3y
0
I posted an answer. Try it out. Dovydas1118 1495 — 3y

2 answers

Log in to vote
1
Answered by 3 years ago

This may be not the exact solution, but you can try UIS:IsKeyDown(). It will check if Q is being held down, and it will return either true or false. There is also a UserInputType alternative, however, it's not related to your answer.

UIS.InputBegan:Connect(function(input, GPE)
    if GPE then return end
    if UIS:IsKeyDown(Enum.KeyCode.Q) then
        if input.UserInputType == Enum.UserInputType.MouseButton1 then
            module.Combo(player)
        end
    end
end)
Ad
Log in to vote
0
Answered by 3 years ago
Edited 3 years ago
local currTimeE1 = 0
local prevTimeE1 = 0
UIS.InputBegan:Connect(function(input, IsTyping)
    if IsTyping then
        return
    elseif input.KeyCode == Enum.KeyCode.Q then             
        module.Punch(player)
        prevTimeE1 = 0
    end
end)


UIS.InputBegan:Connect(function(input, IsTyping)
    if IsTyping then
        return
    elseif input.UserInputType == Enum.UserInputType.MouseButton1 then  
        currTimeE1 = tick()
        local passedtimeE1 = currTimeE1 - prevTimeE1
        if passedtimeE1 < 1 then
            module.Combo(player)
        else
            return

        end

    end
end)



I updated this one, but it still doesnt work

Answer this question