Raycast not working? Ray returns nil

I have a simple grid system in which now I basically intend for the raycast part (redpart above DisplayObject) to shoot a ray to the gridsquare (red) ignoring the green object (DisplayObject). For extra context, DisplayObject is the parent and Raycastpart is the child of DisplayObject. DisplayObject is locally spawned and BasePart was added in ServerSide

If working as intended, it would return the BasePart as the instance, but ray returns nil. The purpose is to check if any objects are placed so that placement would not be allowed.

Local script:

local Parameters = RaycastParams.new()
	Parameters.FilterType = Enum.RaycastFilterType.Exclude
	Parameters.FilterDescendantsInstances = {DisplayObject:GetChildren(),Player}
	local ray = game.Workspace:Raycast(DisplayObject.RayPart.Position, ChosenGridSquare.Position, Parameters)
	
	if ray then
		print(ray)
		print(ray.Instance)
	end

Nevermind, fixed. Had to minus off position for raypart.

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