so i'm making a raycast thats supposed to go in the LookVector direction of a bullet, and it goes in a completely different direction.

i had to post a question because i think its the only thing that can help me at this point.

workspace.BULLET.Touched:Connect(function(h)
	if h.Parent then
		if h.Parent ~= workspace.BULLET and h.CanCollide == true then
			local ignore = workspace.ignoreFolder:GetChildren()
			table.insert(ignore,0,workspace.BULLET)
			for _,v in pairs(workspace.BULLET:GetChildren()) do
				table.insert(ignore,0,v)
			end
			
			local part = Instance.new("Part")
			part.Anchored = true
			part.CanCollide = false
			part.Size = Vector3.new(1,100,1)
			part.Position = workspace.BULLET.CFrame.Position + workspace.BULLET.CFrame.LookVector * 100
			part.Material = "Neon"
			part.Parent = workspace
			
			local part = Instance.new("Part")
			part.Anchored = true
			part.CanCollide = false
			part.Size = Vector3.new(1,100,1)
			part.Position = workspace.BULLET.CFrame.Position + workspace.BULLET.CFrame.LookVector * -100
			part.Material = "Neon"
			part.Parent = workspace
			
			local p0 = workspace.BULLET.CFrame.Position + workspace.BULLET.CFrame.LookVector * -100
			local p1 = workspace.BULLET.CFrame.Position + workspace.BULLET.CFrame.LookVector * 100
			
			print(p0, p1)
			
			local ray0 = Ray.new(p0, p1)
			local hit0, pos0 = workspace:FindPartOnRayWithIgnoreList(ray0,ignore)
			
			print(ray0.Origin, ray0.Direction)
			
			local a = (workspace.BULLET.Position - pos0).Magnitude
			
			local part = Instance.new("Part")
			part.Anchored = true
			part.CanCollide = false
			part.Size = Vector3.new(1,1,a)
			part.CFrame = CFrame.new(workspace.BULLET.Position, pos0) * CFrame.new(0,0,-a/2)
			part.Material = "Neon"
			part.Parent = workspace
			
			local ray1 = Ray.new(pos0,workspace.BULLET.Position--[[ + workspace.BULLET.CFrame.LookVector * (100)]])
			local hit1, pos1 = workspace:FindPartOnRayWithIgnoreList(ray1,ignore)
			
			local ray2 = Ray.new(pos1,pos0)
			local hit2, pos2 = workspace:FindPartOnRayWithIgnoreList(ray2,ignore)
			
			local part = Instance.new("Part")
			part.Anchored = true
			part.Size = Vector3.new(1,100,1)
			part.Position = pos0
			part.Parent = workspace
			
			local part0 = Instance.new("Part")
			part0.Anchored = true
			part0.Size = Vector3.new(1,100,1)
			part0.Position = pos1
			part0.Parent = workspace
			
			local part1 = Instance.new("Part")
			part1.Anchored = true
			part1.Size = Vector3.new(1,100,1)
			part1.Position = pos2
			part1.Parent = workspace
			
			part.Name = 'A'
			part0.Name = 'B'
			part1.Name = 'C'
			
			local thick = (pos0 - pos2).Magnitude
			print(thick)
		end
	end
end)

i apologize for all the messy code, its just i've been trying to fix this for a while now and got impatient.

3 comments

0

I assume you can make the opposite of the lookVector then, so

0

-(workspace.BULLET.CFrame.LookVector) * (100)

0

i already tried that, it gave me the exact same result..