Attempt to index nil with 'Size'

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```

Hey I noticed you didn’t define the variable “laser” anywhere

Edit: nvm but check if the result returns a nil value

The problem in your code is in another script as you invoke the server to define laser. I cannot help you as I don’t know what Event:InvokeServer(“drawbeam”, { Barreloffset, position }) is supposed to return.

Event:InvokeServer("drawbeam",{Barreloffset,position}) returns nil instead of a part. You need to check your server code as well to figure out why this is happening.