Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

Vector3 expected, got number. Anyone know how to fix it?

Asked by 3 years ago

So, I am in the process of making a game. I am adding a laser function inside a module that shoots lasers out of a position, to a position, with some other properties too like range and spread. I have done this lots of times how ever, in my code there seems to be something wrong. Here is the code that has an error ( the middle line ). The problem seems to be coming from the CFrame.new

local DistBetween = (StartPos - RayCastResult.Position).magnitude
Laser.CFrame = DirectionCF * CFrame.new(0, 0 -DistBetween)
Laser.Size = Vector3.new(0.1, 0.1, DistBetween)

Alongside with the variable used, DirectionCF.

local DirectionCF = CFrame.new(StartPos, TargetPos) * CFrame.Angles(math.rad(math.random(-Spread, Spread)), math.rad(math.random(-Spread, Spread)), 0)

Please Help!

0
The only shared attribute between the two is StartPos, I'm suspecting that it is not a Vector3, and was accidentally allocated as Position.[XYZ]? Ziffixture 6913 — 3y

1 answer

Log in to vote
0
Answered by 3 years ago

I have found out the answer by myself. I have found out that I had forgotten the second comma in

CFrame.new(0, 0 -DistBetween)
Ad

Answer this question