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

How to make this gun full Auto with a while loop?

Asked by 3 years ago

I am using my pistol script and editing it to make it a full auto script for my rifle in my game. I tried putting it in a loop a few different ways but I can't get the shoot function to repeat while the mouse is held down. The rifle either shoots semi-auto or not at all, but the pistol (using the original, unedited version of this script) works just fine. I hardly know anything about loops in Lua so I'm just kind of guessing what I'm supposed to do here, if anyone can help that would be great!

while script.Parent.Activated do

    print("fired "..Ammo)

    if Ammo > 0 and not Reloading then
        Ammo -= 1
        print(Ammo)
        script.Parent.GunShot:Play()

        workspace.Camera.CFrame = workspace.Camera.CFrame * CFrame.Angles(0.03,0,0)
        wait()
        workspace.Camera.CFrame = workspace.Camera.CFrame * CFrame.Angles(-0.01,0,0)
        wait()

        if Mouse.Target.Parent:FindFirstChild("Humanoid") then
            script.Parent.DealDamage:FireServer(Mouse.Target.Parent, 26)
        end

    elseif Reloading == false then
        Reload()
        script.Parent.GunShot:Stop()
    end

    while wait() do
        TextLabel.Text = Ammo.."/"..MaxAmmo
    end

end

Answer this question