Needing help with making a gun system more better

Hello, I am using a free model gun script for a game but i want to edit some things to make it a bit better.

Needed help with:
Adding gun shot sounds
Adding a reload function.

Script:
script.Parent.Shoot.OnServerEvent:Connect(function(player,LookAt)
local Gun = player.Backpack:FindFirstChild(“Gun”) or player.Character:FindFirstChild(“Gun”)–rename gun to the tool name
local cframe = Gun.Barrel.CFrame
local bullet = game.ReplicatedStorage.Bullet:Clone()–rename bullet to the name of your bullet if it is different
bullet.Parent = script.Parent
bullet.CFrame = cframe
bullet.Velocity = LookAt*1000 --change this number to what you want the speed of your bullet to go at
local fly = Instance.new(“BodyForce”,bullet)
fly.Force = Vector3.new(0,bullet:GetMass()*196.2,0)
game.Debris:AddItem(bullet,10)
wait()
bullet.Touched:Connect(function()
wait(0.25)
bullet:remove()
end)
end)

Localscript:

script.Parent.Activated:Connect(function()
local pos = script.Parent.Parent.Humanoid.TargetPoint
local LookAt = (pos - script.Parent.Parent.Head.Position).Unit
script.Parent.Shoot:FireServer(LookAt)
end)


Bullet/ Raycast script:local debounce = true
local timebetdamage = 1
script.Parent.Touched:Connect(function(hit)

if hit.Parent:FindFirstChild(“Humanoid”) then
if debounce == true then
debounce = false
hit.Parent.Humanoid:TakeDamage(50)
–change this number here to the amount of damage you’d like your bullet to do
wait(timebetdamage)
debounce = true
end
end

end)

1 Like

Are you asking for someone to feed you the script for doing it? #help-and-feedback:scripting-support isn’t for that purpose, if you want to you can hire someone in #collaboration:recruitment.

Otherwise, you should try before asking a question in this category. But anyways, for adding gun shot sounds, you simply create a sound instance, load the Id and play it whenever your shoot function is run. As you haven’t formated your script properly in a code block, I can’t really find the function that does the shoot part.

For reload function, the logic is simple, I would have a Max Ammo and the Current ammo filled in the gun. Then decrease the Current Ammo on every shot by the number of bullets that are used every shot, and when reload function is run, I would subtract the max Ammo amount from the left Ammo for the gun and add it to the Current Ammo (There needs to be some extra logic for this.)

1 Like

Sorry im very new to devforum so i dont know how to gain access to #help-and-feedback:scripting-support and post there and yes i need someone to feed me the script because i copied the script from a YT video in the comment section.

The #help-and-feedback:scripting-support category is the category that you posted this in. As per the category rules, posts asking “…people to write entire scripts or design entire systems for you,” is prohibited.

You’re better off posting this in #collaboration:recruitment and hiring someone to do this for you, or review tutorials/API documentation and try to figure it out yourself before asking for more help.