I require assistants at this time it is troubling and it keeps failing and there is no thoughts as to why it comes to an end.
function Fire(target)
ShootSFX:Play()
Shoot_Anim:Play()
local targetpos=target+(Vector3.new(math.random()-.5,math.random()-.5,math.random()-.5)*((Handle.Position-target).magnitude/100)*Spread)
local ray=Ray.new(Handle.CFrame.p,(targetpos-Handle.CFrame.p).unit*Range)
local hit,position=workspace:FindPartOnRayWithIgnoreList(ray,Ignore)
local beam=delay(0,function() local laser=Event:InvokeServer("drawbeam",{Barreloffset,position}) laser.CFrame=CFrame.new(Handle.CFrame*Barreloffset.p,position)*CFrame.new(0,0,-laser.Size.Z/2) end)
table.insert(Ignore,beam)
if hit ~= nil then
local humanoid = hit.Parent:FindFirstChild(EnemyType)
local hitplayer=game.Players:GetPlayerFromCharacter(hit.Parent)
if humanoid == nil then
humanoid = hit.Parent.Parent:FindFirstChild(EnemyType)
hitplayer = game.Players:GetPlayerFromCharacter(hit.Parent.Parent)
end
if humanoid ~= nil then
local damagepoints = Damage
if hit.Name=="Head" or hit.Parent.ClassName=="Hat" then
damagepoints = Damage*2
end
if hitplayer~=nil then
if hitplayer.TeamColor ~= LocalPlayer.TeamColor and hitplayer:FindFirstChild("nopvp") == nil and LocalPlayer:FindFirstChild("nopvp")==nil then
Event:InvokeServer("hit",{humanoid,damagepoints})
end
else
Event:InvokeServer("hit",{humanoid,damagepoints})
end
end
end
end```