Sorry if the title is a bit sloppish, but anyway, I’m trying to find a way to allow player to rev up their minigun without firing a single bullet by pressing alt-mouse (Or hold Right Click in simpler terms) via UIS (UserInputService)? Thanks in Advance.
I’m guessing you want the player to not be able to fire the minigun unless it’s rotating?
local userInputService = game:GetService("UserInputService")
local rotating = false
local holdingMouse = false
local function fire()
-- Fire bullet
end
local function rotate()
-- Rotate minigun
end
local function inputBegan(input, processed)
if processed then return end
if input.UserInputType == Enum.UserInputType.MouseButton1 then
holdingMouse = true
if rotating then
repeat
fire()
task.wait(0.01) -- Interval between each shot
until not holdingMouse or not rotating
end
elseif input.UserInputType == Enum.UserInputType.MouseButton2 then
rotating = true
repeat
rotate()
task.wait() -- Interval between each rotation
until not rotating
end
end
local function inputEnded(input, processed)
if processed then return end
if input.UserInputType == Enum.UserInputType.MouseButton1 then
holdingMouse = false
elseif input.UserInputType == Enum.UserInputType.MouseButton2
rotating = false
end
end
userInputService.InputBegan:Connect(inputBegan)
userInputService.InputEnded:Connect(inputEnded)
Somewhat, but what I mean is that I want both the Right and Left Mouse Button to roll the barrel, although I only want the left mouse button to fire the gun.
local CAS = game:GetService("ContextActionService")
local rotating = false
local holdingMouse = false
local function fire()
--You know, your function to fire bullets
end
local function rotate()
while true do
minigun.barrel.CFrame *= CFrame.Angles(math.rad(1), 0, 0) -- rotation, probably not effective, just off the top of my head
end
end
-- From Fizzy in his post above
local function inputBegan(input, processed)
if processed then return end
if input.UserInputType == Enum.UserInputType.MouseButton1 then
holdingMouse = true
if rotating then
repeat
fire()
task.wait(0.01) -- Interval between each shot
until not holdingMouse or not rotating
else
repeat
--os.clock to wait 3 seconds then start firing maybe?
rotating = true
until not holdingMouse or rotating
end
elseif input.UserInputType == Enum.UserInputType.MouseButton2 then
rotating = true
repeat
rotate()
task.wait() -- Interval between each rotation
until not rotating
end
end
CAS:BindAction("revFire", inputBegan, false, Enum.UserInputType.MouseButton1)
CAS:BindAction("rev", inputBegan, false, Enum.UserInputType.MouseButton2)
I want to ask for some clarification, are you trying to achieve it where the player has to hold down the left mouse button and it will have about 2 seconds of the motor revving up to right speed and upon letting go itll slow back down but only when its going fast enough it will start shooting?