How to modify the minigun so it can be revved without firing

Hello There!

As the title says, I want to modify the minigun so it can be revved without firing. Although, for a more detailed approach; I’ve made a minigun thanks to a tutorial, although I want to modify one of the scripts inside of the minigun which is a Local Script that controls if the player is going to use the minigun.

Right now, if the player simply holds the Left Mouse Button, the minigun will rev up for a brief moment before firing. I want to modify that so that if the player holds Right Mouse Button, it will ONLY rev up the minigun, allowing the player to fire the minigun without having to worry about revving up.

Here is a snippet of the current code.

UIS.InputBegan:Connect(function(i, gp)
	if not gp and i.UserInputType == Enum.UserInputType.MouseButton1 and IsEquipped == true then
		Tool.Handle.WindDown:Play()

		OriginalWalkSpeed = Humanoid.WalkSpeed
		OrigianlJumpPower = Humanoid.JumpPower
		Humanoid.WalkSpeed = 4
		Humanoid.JumpPower = 0

		WindupAnim = Humanoid:WaitForChild("Animator"):LoadAnimation(Tool.Use)
		WindupAnim.Priority = Enum.AnimationPriority.Action4
		WindupAnim:Play()

		Tool.Handle.WindDown.Ended:Wait()

		Tool.Handle.Fire:Play()
		--Shoot()
		held = true
	end
end)
1 Like
UIS.InputBegan:Connect(function(i, gp)
	if not gp and i.UserInputType == Enum.UserInputType.MouseButton2 and IsEquipped == true then
		Tool.Handle.WindDown:Play()

		OriginalWalkSpeed = Humanoid.WalkSpeed
		OrigianlJumpPower = Humanoid.JumpPower
		Humanoid.WalkSpeed = 4
		Humanoid.JumpPower = 0

		WindupAnim = Humanoid:WaitForChild("Animator"):LoadAnimation(Tool.Use)
		WindupAnim.Priority = Enum.AnimationPriority.Action4
		WindupAnim:Play()

	
	end
end)

This might work idk I don’t have access to roblox studio so tell me if any errors

you can check like if the player click left or right mouse then it will play the animation and then check if the player click left click the wait and shoot

Yeah, I don’t think it worked.

try

 tool.handle.winddown.ended:connect(funcitoen)
too.handelr.fire:play()
held = true
shoot(
end

do nOT copy this code type it yours elf but base off it

You can try playing the rev-up animation when they start holding down right click, set some sort of debounce variable to true, and then set a variable that tells the script that they’ve already charged up. Something like this:

local chargingUp = false
local chargedUp = false

UIS.InputBegan:Connect(function(i, gp)
    if chargingUp == false then -- so that they cannot rev up while revving up
        if not gp and i.UserInputType == Enum.UserInputType.MouseButton2 and IsEquipped == true then
            chargingUp = true
            -- play animation

            -- after animation is done
            chargedUp = true
        end
    end
end)

We also need to discharge the minigun when right click is let go.
You can just detect when they stop holding, and then set both variables to false.


You can then use the “chargedUp” variable to check if it needs to rev-up when left clicking. (The variable that tells the script that it’s already revved up)

For the “chargingUp” variable, it should be used to see if it should allow the player to shoot or not. (The debounce variable I was talking about earlier)