Professional Documents
Culture Documents
game:GetObjects("rbxassetid://503182370")
[1].Parent=game.Players.LocalPlayer.Backpack
game.Players.LocalPlayer.Backpack.AssaultRifle.Main.Transparency = 0
game.Players.LocalPlayer.Backpack.AssaultRifle.Part1.Transparency = 0
game.Players.LocalPlayer.Backpack.AssaultRifle.Part2.Transparency = 0
game.Players.LocalPlayer.Backpack.AssaultRifle.Part3.Transparency = 0
game.Players.LocalPlayer.Backpack.AssaultRifle.Part4.Transparency = 0
game.Players.LocalPlayer.Backpack.AssaultRifle.Partkaas.Transparency = 0
game.Players.LocalPlayer.Backpack.AssaultRifle.Part5.Transparency = 0
game.Players.LocalPlayer.Backpack.AssaultRifle.Part6.Transparency = 0
game.Players.LocalPlayer.Backpack.AssaultRifle.Part7.Transparency = 0
game.Players.LocalPlayer.Backpack.AssaultRifle.Part8.Transparency = 0
game.Players.LocalPlayer.Backpack.AssaultRifle.Part9.Transparency = 0
game.Players.LocalPlayer.Backpack.AssaultRifle.Part10.Transparency = 0
game.Players.LocalPlayer.Backpack.AssaultRifle.Part11.Transparency = 0
game.Players.LocalPlayer.Backpack.AssaultRifle.Part12.Transparency = 0
game.Players.LocalPlayer.Backpack.AssaultRifle.Part13.Transparency = 0
-- Colors
local FriendlyReticleColor = Color3.new(0, 1, 0)
local EnemyReticleColor = Color3.new(1, 0, 0)
local NeutralReticleColor = Color3.new(1, 1, 1)
local LeftButtonDown
local Reloading = false
local IsShooting = false
local RecoilAnim
local RecoilTrack = nil
-- this is a dummy object that holds the flash made when the gun is fired
local FlashHolder = nil
-- @preconditions: vec should be a unit vector, and 0 < rayLength <= 1000
function RayCast(startPos, vec, rayLength)
local hitObject, hitPos = game.Workspace:FindPartOnRay(Ray.new(startPos +
(vec * .01), vec * rayLength), Handle)
if hitObject and hitPos then
local distance = rayLength - (hitPos - startPos).magnitude
if RayIgnoreCheck(hitObject, hitPos) and distance > 0 then
-- there is a chance here for potential infinite recursion
return RayCast(hitPos, vec, distance)
end
end
return hitObject, hitPos
end
function OnFire()
if IsShooting then return end
if MyHumanoid and MyHumanoid.Health > 0 then
if RecoilTrack and AmmoInClip > 0 then
RecoilTrack:Play()
end
IsShooting = true
while LeftButtonDown and AmmoInClip > 0 and not Reloading do
if Spread and not DecreasedAimLastShot then
Spread = math.min(MaxSpread, Spread +
AimInaccuracyStepAmount)
UpdateCrosshair(Spread)
end
CreateFlash()
if MyMouse then
local targetPoint = MyMouse.Hit.p
local shootDirection = (targetPoint - Handle.Position).unit
-- Adjust the shoot direction randomly off by a little bit
to account for recoil
shootDirection = CFrame.Angles((0.5 - math.random()) * 2 *
Spread,
local TargetHits = 0
function UpdateTargetHit()
TargetHits = TargetHits + 1
if WeaponGui and WeaponGui:FindFirstChild('Crosshair') and
WeaponGui.Crosshair:FindFirstChild('TargetHitImage') then
WeaponGui.Crosshair.TargetHitImage.Visible = true
end
wait(0.5)
TargetHits = TargetHits - 1
if TargetHits == 0 and WeaponGui and WeaponGui:FindFirstChild('Crosshair')
and WeaponGui.Crosshair:FindFirstChild('TargetHitImage') then
WeaponGui.Crosshair.TargetHitImage.Visible = false
end
end
function UpdateAmmo(value)
if WeaponGui and WeaponGui:FindFirstChild('AmmoHud') and
WeaponGui.AmmoHud:FindFirstChild('ClipAmmo') then
WeaponGui.AmmoHud.ClipAmmo.Text = AmmoInClip
if value > 0 and WeaponGui:FindFirstChild('Crosshair') and
WeaponGui.Crosshair:FindFirstChild('ReloadingLabel') then
WeaponGui.Crosshair.ReloadingLabel.Visible = false
end
end
if WeaponGui and WeaponGui:FindFirstChild('AmmoHud') and
WeaponGui.AmmoHud:FindFirstChild('TotalAmmo') then
WeaponGui.AmmoHud.TotalAmmo.Text = SpareAmmo
end
end
function OnMouseDown()
LeftButtonDown = true
OnFire()
end
function OnMouseUp()
LeftButtonDown = false
end
function OnKeyDown(key)
if string.lower(key) == 'r' then
Reload()
end
end
function OnEquipped(mouse)
RecoilAnim = WaitForChild(Tool, 'Recoil')
MyCharacter = Tool.Parent
MyPlayer = game:GetService('Players'):GetPlayerFromCharacter(MyCharacter)
MyHumanoid = MyCharacter:FindFirstChild('Humanoid')
MyTorso = MyCharacter:FindFirstChild('Torso')
MyMouse = mouse
WeaponGui = WaitForChild(Tool, 'WeaponHud'):Clone()
if WeaponGui and MyPlayer then
WeaponGui.Parent = MyPlayer.PlayerGui
UpdateAmmo(AmmoInClip)
end
if RecoilAnim then
RecoilTrack = MyHumanoid:LoadAnimation(RecoilAnim)
end
if MyMouse then
-- Disable mouse icon
MyMouse.Icon = "http://www.roblox.com/asset/?id=18662154"
MyMouse.Button1Down:connect(OnMouseDown)
MyMouse.Button1Up:connect(OnMouseUp)
MyMouse.KeyDown:connect(OnKeyDown)
end
end
Tool.Equipped:connect(OnEquipped)
Tool.Unequipped:connect(OnUnequipped)
while true do
wait(0.033)
if WeaponGui and WeaponGui:FindFirstChild('Crosshair') and MyMouse then
WeaponGui.Crosshair.Position = UDim2.new(0, MyMouse.X, 0, MyMouse.Y)
SetReticleColor(NeutralReticleColor)