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

How do I make a gear that does something on keypress?

Asked by 6 years ago

For starters, I want to make a gear that increases my walkspeed and health by 30 if I press ' e '. I tried UserInput and Keypress, but failed :(. I want to do more advanced stuff with it on the future like summoning and combining with a monster (RPG).

0
Could you show your script for UserInput? I can't help unless I know what you did wrong. Troidit 253 — 6y
0
local h = script.Parent.Parent function onKeyPress(inputObject, gameProcessedEvent) if inputObject.KeyCode == Enum.KeyCode.R then h.Humanoid.WalkSpeed = 30 h.Humanoid.MaxHealth = 300 end end game:GetService("UserInputService").InputBegan:connect(onKeyPress) xxXTimeXxx 101 — 6y

1 answer

Log in to vote
0
Answered by 6 years ago

Pretty easy!

you can add this is the code:

local players = game:GetService("Players")
local player = players.LocalPlayer
local mouse = player:GetMouse()
local tool = [SPECIFY WHERE THE TOOL IS HERE]

local equipped = false

tool.Equipped:connect(function()
    equipped = true
end)

tool.Unequipped:connect(function()
    equipped = false
end)

mouse.KeyDown:connect(function(Key)
    if Key:lower() then
        if Key == "f" then 
            --insert code
        end
    end
end)
0
I modified it to this xxXTimeXxx 101 — 6y
0
local tool = script.Parent local h = tool.Parent if Key:lower() then if Key == "f" then h.Humanoid.MaxHealth = 300 end and put it inside the gear in a local script, but it doesnt work xxXTimeXxx 101 — 6y
Ad

Answer this question