Vector3 expected, got number. Anyone know how to fix it?
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
1 | local DistBetween = (StartPos - RayCastResult.Position).magnitude |
2 | Laser.CFrame = DirectionCF * CFrame.new( 0 , 0 -DistBetween) |
3 | Laser.Size = Vector 3. new( 0.1 , 0.1 , DistBetween) |
Alongside with the variable used, DirectionCF.
1 | local DirectionCF = CFrame.new(StartPos, TargetPos) * CFrame.Angles(math.rad(math.random(-Spread, Spread)), math.rad(math.random(-Spread, Spread)), 0 ) |
Please Help!