I'm asking this question to know what to do to assign hotkeys. For example in most fighting games, if you press Q you'd do a punch or a kick. Could any of you guys tell me a script that will help me with something like that? Many thanks!
Here is the script for this
01 | local function onInputBegan(input,gameProcessed) |
02 | if input.UserInputType = = Enum.UserInputType.Keyboard then |
03 | local keyPressed = input.KeyCode |
04 | if string.upper(keyPressed) = = "Q" then |
05 | . -- Function here |
06 | . end |
07 | end |
08 | end |
09 | |
10 | UserInputService.InputBegan:connect(onInputBegan) |
This script allows you to equip a tool by pressing a key and unequip it by pressing the same key put this inside the tool then put the tool in the starter pack
01 | local player = game:GetService( "Players" ).LocalPlayer; |
02 | local mouse = player:GetMouse(); |
03 | local tool = player.Backpack.Rasengan; -- change to tool name |
04 | local toggle = false |
05 |
06 | mouse.KeyDown:connect( function (key) |
07 | if toggle = = false and key = = "r" then --change hot key inside "" |
08 | player.Character.Humanoid:EquipTool(tool); |
09 | toggle = true |
10 | elseif toggle = = true and key = = "r" then --change hot key inside "" |
11 | player.Character.Humanoid:UnequipTools(tool); |
12 | toggle = false |
13 | end |
14 | end ); |