Issue with lookVector

  1. What do you want to achieve? I want to create a fireball, where it shoots out from your HumanoidRootPart, specifically wherever it’s looking. I was going to accomplish this using lookVector.

  2. What is the issue? I get the same error, no matter what I try: 18:06:10.643 - ServerScriptService.FireballServer:14: invalid argument #3 (CFrame expected, got Vector3)

  3. What solutions have you tried so far? I’ve tried using Vector3’s instead, but that doesn’t work. I’ve searched up this on different websites, including this, and couldn’t find my answer there…

	local char = player.Character
	local humRP = char:WaitForChild("HumanoidRootPart")
	local cf = humRP.CFrame
	FBall.Anchored = true
	FBall.CanCollide = true
	FBall.Parent = workspace
	FBall.CFrame = cf.lookVector

Please help!

1 Like

If you want it to have velocity and go in a specific direction, I would recommend trying out something like this (you can use body movers as well if you want):

FBall.Velocity = cf.lookVector * 200 --Whatever velocity you want

As for setting the initial CFrame, you could put it just ahead of the root part if you want. Just play around with it and see what you like. Hope this helps :slight_smile:

It’s because lookVector returns a Vector3 value when it’s not multiplied by anything. lookVector returns the forward direction of a CFrame’s orientation, not a full CFrame. Try multiplying lookVector as @lifacy suggested!

1 Like

You can’t set a CFrame to a vector. LookVector is a vector which has a length of 1.

Try:

FBall.Position = cf.lookVector

That is completely irrelevant to the problem.

Hello, I think you are doing the wrong at the

FBall.CFrame = cf.lookVector

Part.
First of all lookVector does not return a CFrame. It returns a Vector3 Value.
To solve this, you could do

FBall.CFrame = CFrame.new(cf.lookVector) --According to wiki,
--this part creates a CFrame from a Vector3 value,
--And so you can easily set the part's CFrame.

Well in this part I also noticed something but I am not too sure.
You want to ‘shoot’ something but, it seems like you’re just setting the CFrame of the part to target place. I recommend you to use BodyVelocity for this. (Or tweening?)
Well, I hope I could solve your problem!

Replace
FBall.CFrame = cf.lookVector

With
FBall.CFrame = cf + cf.LookVector * 5

This spawns the fireball 5 studs in front of the player’s HumanoidRootPart as you desired.