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

How would I assign hotkeys for attacks,tools, etc?

Asked by 8 years ago

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!

0
Ill give the script. wait a minute Etheroit 178 — 8y

2 answers

Log in to vote
0
Answered by
Etheroit 178
8 years ago

Here is the script for this

01local 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
08end
09  
10UserInputService.InputBegan:connect(onInputBegan)
0
input.KeyCode is upper case http://wiki.roblox.com/?title=API:Enum/KeyCode User#5423 17 — 8y
0
Can u also explain what element in script allows to do this and that? Cause it's complicated, and I can't tweak it unless it's self explanatory to me? Thnx alot Kingaskhan -5 — 8y
Ad
Log in to vote
0
Answered by
AM910sk 22
5 years ago
Edited 5 years ago

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

01local player = game:GetService("Players").LocalPlayer;
02local mouse = player:GetMouse();
03local tool = player.Backpack.Rasengan;-- change to tool name
04local toggle = false
05 
06mouse.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
14end);

Answer this question