Module script attempt to index nil with CFrame

I’m in a gamejam trying to make a parkour system, and for the climbing mechanic, each frame, the ClimbInitializer (local script) requires the ClimbHandler (module) to run the function WallCheck(), which casts a ray from humanoid rootpart to the lookvector. afterwards it gets the instance it hit, its position, and is supposed to get the Attribute “Climbable” from it, then returns some stuff about the hit instance.

the issue is that i get an error for ‘CFrame’ on line 6, which is confusing me because i thought that module scripts could get the cframe or the position of an instance? i tried .Position, .CFrame.Position, but neither worked.

ive got no clue what the issue is, ive checked the module script documentation for any info on the cframes, but either i skipped over something or there isnt any info on instance positions in a module.

module script:

local humanoidRootPart = script.Parent.Parent:WaitForChild("HumanoidRootPart")
local char = humanoidRootPart.Parent
local module = {}
	
function module.WallCheck(humanoidRootPart, char)
	local ray = Ray.new(humanoidRootPart.CFrame, humanoidRootPart.CFrame.LookVector * 2) 
	local hit, position = workspace:FindPartOnRay(ray, char)

	local Climbable = hit:GetAttribute("Climbable")

	if Climbable == true then
		return hit and hit:IsA("Part") and not hit:IsDescendantOf(char)
	else
		print("not climbable part")
	end



end


return module

function that calls module script

local function isNearWall()

require(script.ClimbHandler).WallCheck()
end

You aren’t providing the arguments that you are meant to. You need to provide the HumanoidRootPart and the char (from function module.WallCheck(humanoidRootPart, char)

I suspect you just forgot to remove humanoidRootPart and char from line 5.

1 Like

bruhhhhhhhh i genuinely get so disappointed in myself im slow loool

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.