Ad
Still have questions? Join our Discord server and get real time help.
Log in to vote
0

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

Asked by 3 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 DevKurka 173 — 3y

2 answers

Log in to vote
0
Answered by
DevKurka 173
3 years ago

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)
0
input.KeyCode is upper case http://wiki.roblox.com/?title=API:Enum/KeyCode User#5423 -10 — 3y
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 — 3y
Ad
Log in to vote
0
Answered by
AM910sk 22
7 months ago
Edited 7 months 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

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

Answer this question