Trying to create gun spread. "LookVector is not a valid member of Vector3"

I have been trying to add gun spread to my gun for the past few hours but I can’t find a solution. I think I found a away to make gun spread but I am keep one getting this error LookVector is not a valid member of Vector3. I am using fast cast to create this.
Here is the script segment:

local function fire(player, mousePosition)
	if toolEquipped then
		if ammoLeft > 0 and not reloading then
			local origin = firePoint.WorldPosition --Not Position because position in attachments is local not global
			local endPos = mousePosition
			local startPos = firePoint.WorldPosition

			local CF = CFrame.new(startPos,endPos)*CFrame.Angles(math.rad(math.random(-15,15)),math.rad(math.random(-15,15)),0)

			local DirVec = CF.LookVector
			caster:Fire(origin, DirVec.LookVector, vel, castBehavior)
			sound.playSound("shoot")
			ammoLeft -= 1
		else
			reload()
		end
	end
end

Change this line to this:

caster:Fire(origin, DirVec, vel, castBehavior)

You are indexing LookVector twice.

4 Likes

TYSM, I am so stupid but thank you. I am tired so I probably couldn’t concentrate.

1 Like