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

how do i make this gun automatic with a easy to change rpm (how fast the gun shoots)? [CLOSED]

Asked by 4 years ago
Edited 4 years ago

this is my script

this makes the gun semi auto but i want it to be automatic

local tool = script.Parent
local player = game:GetService("Players").LocalPlayer

tool.Equipped:connect(function(mouse)
    print("Tool equipped!")

    mouse.Button1Down:connect(function()
        print("Mouse pressed!")
        local ray = Ray.new(tool.Muzzle.CFrame.p, (mouse.Hit.p - tool.Muzzle.CFrame.p).unit * 300)
        local part, position = workspace:FindPartOnRay(ray, player.Character, false, true)

        local beam = Instance.new("Part", workspace)
        beam.BrickColor = BrickColor.new("Toothpaste")
        beam.FormFactor = "Custom"
        beam.Material = "Neon"
        beam.Transparency = 0.25
        beam.Anchored = true
        beam.Locked = true
        beam.CanCollide = false

        local distance = (tool.Muzzle.CFrame.p - position).magnitude
        beam.Size = Vector3.new(0.3, 0.3, distance)
        beam.CFrame = CFrame.new(tool.Muzzle.CFrame.p, position) * CFrame.new(0, 0, -distance / 2)

        game:GetService("Debris"):AddItem(beam, 0.1)

        if part then
            local humanoid = part.Parent:FindFirstChild("Humanoid")

            if not humanoid then
                humanoid = part.Parent.Parent:FindFirstChild("Humanoid")
            end

            if humanoid then
                humanoid:TakeDamage(30)
            end
        end
    end)
end)

if i put a loop it crashes the studio and the game itself

0
I recommend free models for guns there is one that works and allows you to create any weapon with any settings BabanizPROcuk 49 — 4y
0
use a loop but with wait() or game:GetService("RunService").Heartbeat:Wait() maumaumaumaumaumua 628 — 4y
0
where would i put the loop around @maumaumaumaumaumua ProjectInfiniti 192 — 4y
0
nvm i got it ProjectInfiniti 192 — 4y

Answer this question