Unable to cast double into Vector3 error, how do I fix it?

  1. What do you want to achieve? I want to achieve a hitscan module that can be used for guns and stuff.

  2. What is the issue? It keeps doing the “Unable to cast double into Vector3 :nerd_face:” for some reason.

  3. What solutions have you tried so far? I have looked for solutions on DevForum, ScriptingHelpers and Google. None of them worked, to say the least.

Does anyone know how to fix this issue? If so, how?
Here’s the code:

local module = {}
local ws = workspace

function module:CastBullet(startpos:Vector3,endpos:Vector3,damage:number,rp:RaycastParams,bulletcolor:BrickColor?)
	if not bulletcolor then bulletcolor = BrickColor.new("Bright yellow") end
	local result = ws:Raycast(startpos,CFrame.lookAt(startpos,endpos):ToOrientation(),rp)
	if result and result.Instance then
		print("raycast success")
	end
end

return module

The error lies at line 6.

Because CFrame:ToOrientation() returns a tuple (Z, X, Y). endpos - startpos should be fine.

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.