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

[Solved] UnequipTools() on key press?

Asked by 6 years ago
Edited 6 years ago

Issue resolved

local Humanoid = script.Parent:FindFirstChild("Humanoid")
function onKeyPress(inputObject, gameProcessedEvent)
    if inputObject.KeyCode == Enum.KeyCode.Q then
        Humanoid:UnequipTools()
    end
end

game:GetService("UserInputService").InputBegan:connect(onKeyPress)

1 answer

Log in to vote
0
Answered by
LuaDLL 253 Moderation Voter
6 years ago

Create a LocalScript Inside StarterCharacterScripts

local Humanoid = script.Parent:FindFirstChild("Humanoid")
function onKeyPress(inputObject, gameProcessedEvent)
    if inputObject.KeyCode == Enum.KeyCode.Q then
        Humanoid:UnequipTools()
    end
end

game:GetService("UserInputService").InputBegan:connect(onKeyPress)

0
That works, many thanks. I had it in StarterGui out of habit. matbelle 15 — 6y
0
No problem bro LuaDLL 253 — 6y
Ad

Answer this question