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

Making key combination using UserInputService?

Get it? It's like when you hold down a button and press another button, it triggers something.

And also, how to make the script knows that the player has stopped pressing those keys?

1 answer

✓ Accepted answer

Hello,

local ui = game:GetService("UserInputService") -- Get the UserInputService.

ui.InputBegan:Connect(function(input,gpe)
	if not gpe then -- If not on a gui.
		if ui:IsKeyDown(Enum.KeyCode.Space) and ui:IsKeyDown(Enum.KeyCode.W) then -- If Space AND W are being held down/ pressed at the same time, it will trigger the event you want.(In this case print)
			print("~Stuff here~")
		end
	end
end)

Reference here for the IsKeyDown() function.

You can also check KeyCodes here

If you have any question feel free to ask.

Thank you for reading.

2 comments

0

This was really helpful !

0

@arshad145 And how to know if the player has stopped pressing those buttons?

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