Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- wait(2)
- local tool = script.Parent
- local player = game:GetService("Players").LocalPlayer
- local gunshotevent = game.ReplicatedStorage.Gunshot
- local settings = tool.Settings
- local gui = player.PlayerGui.MainGUI
- --Load the gun stats
- local damage = settings.Damage.Value
- local magsize = settings.MagSize.Value
- local debouncetime = settings.DebounceTime.Value
- local reloadtime = settings.ReloadTime.Value
- local range = settings.Range.Value
- local mags = settings.Mags.Value
- local debounce = false
- local mag = magsize
- local reloaddebounce = false
- gui.InGame.WeaponName.Text = tool.Name
- gui.InGame.AmmoAmount.Text = mag.."/"..(mags*magsize)
- tool.Equipped:connect(function(mouse)
- settings:Destroy()
- mouse.Button1Down:connect(function()
- if debounce == false and mag > 0 then
- local hit = mouse.Hit.p
- local muzzle = script.Parent.Muzzle
- gunshotevent:FireServer(hit, muzzle, damage, range)
- debounce = true
- mag = mag - 1
- gui.InGame.WeaponName.Text = tool.Name
- gui.InGame.AmmoAmount.Text = mag.."/"..(mags*magsize)
- wait(debouncetime)
- debounce = false
- tool.Handle.Fire:Play()
- local anim1 = player.Character.Humanoid:LoadAnimation(tool.Handle.FireAnim)
- anim1:Play()
- else
- if mag == 0 and mags > 0 and reloaddebounce == false then
- reloaddebounce = true
- gui.InGame.AmmoAmount.Text = "Reloading"
- tool.Handle.Reload:Play()
- local anim = player.Character.Humanoid:LoadAnimation(tool.Handle.ReloadAnim)
- anim:Play()
- wait(reloadtime)
- mag = magsize
- mags = mags - 1
- gui.InGame.WeaponName.Text = tool.Name
- gui.InGame.AmmoAmount.Text = mag.."/"..(mags*magsize)
- reloaddebounce = false
- end
- end
- end)
- end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement