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!
✓ ANSWER ACCEPTED
How would I assign hotkeys for attacks,tools, etc?
2 answers
✓ Accepted answer
Here is the script for this
local function onInputBegan(input,gameProcessed)
if input.UserInputType == Enum.UserInputType.Keyboard then
local keyPressed = input.KeyCode
if string.upper(keyPressed) == "Q" then
. -- Function here
. end
end
end
UserInputService.InputBegan:connect(onInputBegan)
2 comments
0
input.KeyCode is upper case http://wiki.roblox.com/?title=API:Enum/KeyCode
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
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
local player = game:GetService("Players").LocalPlayer;
local mouse = player:GetMouse();
local tool = player.Backpack.Rasengan;-- change to tool name
local toggle = false
mouse.KeyDown:connect(function(key)
if toggle == false and key == "r" then --change hot key inside ""
player.Character.Humanoid:EquipTool(tool);
toggle = true
elseif toggle == true and key == "r" then --change hot key inside ""
player.Character.Humanoid:UnequipTools(tool);
toggle = false
end
end);
This discussion is preserved as it was. New answers, comments, and votes are closed.

1 comment
Ill give the script. wait a minute