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!
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)