This is the part that does the shooting. It's the hyperlaser gun from the catalog.
local function OnActivated()
if Tool.Enabled and Humanoid.Health > 0 then
Tool.Enabled = false
FireSound:Play()
local handleCFrame = Handle.CFrame
local firingPoint = handleCFrame.p + handleCFrame:vectorToWorldSpace(NOZZLE_OFFSET)
local shotCFrame = CFrame.new(firingPoint, Humanoid.TargetPoint)
local laserShotClone = BaseShot:Clone()
laserShotClone.CFrame = shotCFrame + (shotCFrame.lookVector * (BaseShot.Size.Z / 2))
local bodyVelocity = Instance.new('BodyVelocity')
bodyVelocity.velocity = shotCFrame.lookVector * SHOT_SPEED
bodyVelocity.Parent = laserShotClone
laserShotClone.Touched:connect(function(otherPart)
OnTouched(laserShotClone, otherPart)
end)
DebrisService:AddItem(laserShotClone, SHOT_TIME)
laserShotClone.Parent = Tool
wait(0.6) -- FireSound length
ReloadSound:Play()
wait(0.75) -- ReloadSound length
Tool.Enabled = true
end
end |