Issues With My Module (CFrames)

Ive tried changing a few things around but its not working still, any help would be appreciated.

Error Message:
Workspace.Modules.RayPhoto:19: attempt to index nil with number - Server - RayPhoto:19

Line 19:

Temp[1] = Vector3.new(StartPos.X,StartPos.Y,StartPos.Z)

The script (Up to point of ray firing)

local RayCasting = require(game.Workspace.Modules.RayCasting)
local CFModule = require(game.Workspace.Modules.CFModule)
local Temp = nil

local RayPhoto = {}

function RayPhoto.TakePhoto(StartPos,Distance,Inc,LoopTime)
	StartPos = CFrame.new(StartPos.X,StartPos.Y,StartPos.Z)
	print("StartPos")
	print(StartPos)
	print(StartPos + StartPos.LookVector * Distance)
	
	local RealValues = {360,360,360}
	local TempValues = {360,360,360}
	local Pos = {}
	while TempValues[1] > 0 do
		while TempValues[2] > 0 do
			while TempValues[3] > 0 do
				Temp[1] = Vector3.new(StartPos.X,StartPos.Y,StartPos.Z)-- <---
				Temp[2] = StartPos + StartPos.LookVector * Distance
				Temp[2] = Vector3.new(Temp[2].X,Temp[2].Y,Temp[2].Z)
				
				
				local Result = RayCasting.FireRay(Temp[1],Temp[2])

Change local Temp = nil to local Temp = {}

Ive done that and also corrected a few other errors. Cheers
Sometimes when you been looking at scripts for too long its hard to spot small stuff like that

1 Like

Yeah that’s understandable and even very relatable. No worries lol. My computer science teacher used to always say sometimes we overthink small things and so it’s nice to have a thought buddy just to get some other perspective into the question.

1 Like