0% found this document useful (0 votes)
9 views

Message

lol

Uploaded by

DeLi KaFa
Copyright
© © All Rights Reserved
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
9 views

Message

lol

Uploaded by

DeLi KaFa
Copyright
© © All Rights Reserved
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 2

local tool = script.

Parent
local remote = tool:WaitForChild("OnShoot")
local maxAmmo = 14
local CoolDown = 0.002
local ammo = maxAmmo
local reloading = false

local Players = game:GetService("Players")


local client = Players.LocalPlayer
local cursor = client:GetMouse()
local CAS = game:GetService("ContextActionService")
local Camera = game:GetService("Workspace").CurrentCamera

local plrgui = client.PlayerGui


local text = plrgui:WaitForChild("Ammo").AmmoCount

local BoolValue = script.Parent:WaitForChild("EquippedValue")

local ZoomTypes = { Enum.UserInputType.MouseButton2, Enum.KeyCode.ButtonL2 }


local ReloadTypes = { Enum.KeyCode.R, Enum.KeyCode.ButtonX }
local FireTypes = { Enum.UserInputType.MouseButton1, Enum.KeyCode.ButtonR2 }
local gunCooldown = false

local function GunHandler(ActionName, inputState, inputObject)


if ActionName == "WeaponZoom" and BoolValue.Value and inputState ==
Enum.UserInputState.Begin and (table.find(ZoomTypes, inputObject.UserInputType) or
table.find(ZoomTypes, inputObject.KeyCode)) then
Camera.FieldOfView = 40
client.Character:WaitForChild("Humanoid").WalkSpeed = 14.5
plrgui:WaitForChild("HotBarGUI").Enabled = false
end

if ActionName == "WeaponZoom" and inputState == Enum.UserInputState.End and


(table.find(ZoomTypes, inputObject.UserInputType) or table.find(ZoomTypes,
inputObject.KeyCode)) then
Camera.FieldOfView = 70
client.Character:WaitForChild("Humanoid").WalkSpeed = 17.5
plrgui:WaitForChild("HotBarGUI").Enabled = true
end

if ActionName == "Reload" and BoolValue.Value and table.find(ReloadTypes,


inputObject.KeyCode) and not reloading then
reloading = true
tool.Handle.reload:Play()
task.wait(1)
ammo = maxAmmo
reloading = false
end

if ActionName == "FireWeapon" and BoolValue.Value and (table.find(FireTypes,


inputObject.UserInputType) or table.find(FireTypes, inputObject.KeyCode)) and not
reloading and ammo > 0 and not gunCooldown then
gunCooldown = true
ammo = ammo - 1
task.wait(CoolDown)
remote:FireServer(cursor.Hit.Position)
tool.Handle.gunshot:Play()
tool.Handle.PointLight.Enabled = true
task.wait(0.2)
tool.Handle.PointLight.Enabled = false
task.delay(CoolDown, function() gunCooldown = false end)
elseif ActionName == "FireWeapon" and BoolValue.Value and
(table.find(FireTypes, inputObject.UserInputType) or table.find(FireTypes,
inputObject.KeyCode)) and not reloading and not gunCooldown then
reloading = true
tool.Handle.reload:Play()
task.wait(1)
ammo = maxAmmo
reloading = false
tool.Handle.gunshot:Stop()
end
end

task.spawn(function()
while true do
text.Text = (ammo).." / "..tostring(maxAmmo)
task.wait()
end
end)

tool.Equipped:Connect(function()
BoolValue.Value = true

cursor.Icon = "rbxassetid://42445293"

plrgui.Ammo.Enabled = true
text.DisableScript.Disabled = true
plrgui.Shop.Enabled = false
plrgui.Inventory.Enabled = false

CAS:BindAction("FireWeapon", GunHandler, true,


Enum.UserInputType.MouseButton1, Enum.KeyCode.ButtonR2)
CAS:BindAction("Reload", GunHandler, true, Enum.KeyCode.R,
Enum.KeyCode.ButtonX)
CAS:BindAction("WeaponZoom", GunHandler, true,
Enum.UserInputType.MouseButton2, Enum.KeyCode.ButtonL2)

end)

script.Parent.Unequipped:Connect(function()
plrgui.Ammo.Enabled = false
text.DisableScript.Disabled = false
plrgui.Shop.Enabled = true
plrgui.HotBarGUI.Enabled = true
plrgui.Inventory.Enabled = true

BoolValue.Value = false

Camera.FieldOfView = 70
client.Character:WaitForChild("Humanoid").WalkSpeed = 17.5
plrgui:WaitForChild("HotBarGUI").Enabled = true

CAS:UnbindAction("FireWeapon")
CAS:UnbindAction("Reload")
CAS:UnbindAction("WeaponZoom")
end)

You might also like