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).
COMMUNITY QUESTION
How do I make a gear that does something on keypress?
1 answer
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)
2 comments
0
I modified it to this
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
This discussion is preserved as it was. New answers, comments, and votes are closed.

2 comments
Could you show your script for UserInput? I can't help unless I know what you did wrong.
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)