So I have built a sniper rifle with bipod and everything. It's a tool but I want you to be able to Pull up and down the bipod when pressing F. I only want it so I can make one invisble and the other visible by pressing F.
Any help is very appreciated! //ItsRickGrimes
You can use the UserInputService
to detect if a key is being pressed, then you can make it do what you want. An example is shown here :
This is the InputBegan
which detects when the key is pressed
local UIS = game:GetService("UserInputService") UIS.InputBegan:Connect(function(Input, gameProcessedEvent) local KeyCode = Input.KeyCode if not gameProcessedEvent then if KeyCode == Enum.KeyCode.F then --do what you want here end end end)
This is the InputEnded
which detects when the key is released
local UIS = game:GetService("UserInputService") UIS.InputEnded:Connect(function(Input, gameProcessedEvent) local KeyCode = Input.KeyCode if not gameProcessedEvent then if KeyCode == Enum.KeyCode.F then --do what you want here end end end)