Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

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

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!

1 comment

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]?

1 answer

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)

This discussion is preserved as it was. New answers, comments, and votes are closed.