Need a Simple Gun System

Hello, I am looking for a relatively simple third-person gun system for my game. I’ve looked all over and I can’t find any good ones. All I would like is a recommendation on a good system, simple but with a decent amount of customization, a way to prevent team killing, R6 support and little to no lag (these last two are the most important.) And I’m not asking for anyone to make me a kit.

I’d script it myself but I have no idea how, if there was a good tutorial I’d take that as well.

4 Likes

As I can’t help you find a model, I can help you create your own using small steps;

First,
You’ll want to lock the camera in the shift-lock state I assume? You can easily search for a “force shift lock” script or search how to script a third person camera similar to it.

Second, the guns.
I’d recommend against using tools, and scripting your own system.
For raycasting, you’ll want to raycast from the barrel to the mouse, which you can use code like this to achieve:

-- RayRange is the distance of the gun
local RayDirection = (Gun.Front.Position - Mouse.Hit.Position).Unit * -RayRange
local Raycast = workspace:Raycast(Gun.Front.Position, RayDirection, RaycastParams)

You can then bind animations to certain events in the gun, such as firing, sprinting or reloading.

Speaking of, if you’re not going to use tools, you’ll need to use UserInputService!

local UIS = game:GetService("UserInputService")
local FiringGun = false

-- This may need tweaks as I may have misspelt some things
UIS.InputBegan:Connect(function(Input, Processed)
    if Input.UserInputType == Enum.UserInputType.MouseButton1 then
        print("Fire Start!")
        FiringGun = true
    end
end
UIS.InputEnded:Connect(function(Input, Processed)
    if Input.UserInputType == Enum.UserInputType.MouseButton1 then
        print("Fire End!")
        FiringGun = false
    end
end

and to make the gun fire, you could bind a fire function to framerate.

local RunService = game:GetService("RunService")
local BulletsPerSecond = 5
local Rate = 1/BulletsPerSecond
local Accumulated = 0

function Fire(Delta)
    Accumulated += Delta
    if FiringGun and Accumulated >= Rate then
        Accumulated -= Rate
        -- fire the gun bla bla bla
    end
end

RunService:BindToRenderStep("FireGunFunction", Enum.RenderPriority.Character.Value, Fire)

you can then do some extra stuff to allow for seperate gun types, such as automatic, manual, burst and shotguns.

Hope this helps you!

1 Like

Thank you, I may try this tomorrow, but I do want to use tools.

you can then do some extra stuff to allow for seperate gun types, such as automatic, manual, burst and shotguns.

How would I manage a shotgun effect?

Would highly recommend Fast Cast Redux: Making a combat game with ranged weapons? FastCast may be the module for you!

Simple to get going with the examples and can be extended fairly easily to all kinds of ranged weapons