Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

why MouseButton1 and UserInputType not working?

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

8 comments

0

It's because it runs only one time, it can't be Q and the mouse button at the same time.

0

is there a way to make a combo with Q and mouse button

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.

0

ill try that

0

it still doesnt work

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. 

0

I updated, but it still doesnt work. Canyou give me an exmaple

0

I posted an answer. Try it out.

2 answers

✓ Accepted answer

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)
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

This discussion is preserved as it was. New answers, comments, and votes are closed.