Can't pass CFrame

i am trying to send CFrame from server script to ModuleScript Located in Replicated Storage

I can’t pass it for some reason

server side:

local Players = game:GetService("Players")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local TryPlace = ReplicatedStorage.TryPlace
local placeableObjects = ReplicatedStorage.PlaceableObjects
local PlacementValidator = require(ReplicatedStorage.PlacementValidator)


function Place(player: Player, name: string, targetCF: CFrame): boolean
	local object = placeableObjects:FindFirstChild(name)

	if not object then
		warn("Object not found:", name)
		return false
	end

	local objectSize = object:GetExtentsSize()

	local simpleCFrame = CFrame.new(0, 0, 0)  -- Test with a simple CFrame
	local success = PlacementValidator.NotIntersectingObjects(objectSize, "simpleCFrame")

	warn("Test with simple CFrame:", success)

	if not PlacementValidator.WithinBounds(objectSize, targetCF)  
		or not PlacementValidator.NotIntersectingObjects(objectSize, targetCF) then
		warn("Placement failed due to bounds or intersection issues.")
		return false 
	end

	local newObject = object:Clone()
	newObject:PivotTo(targetCF)
	newObject.Parent = game.Workspace.PlacedProducts
	warn("Object successfully placed!")
	return true 
end

Module Script:

local PlacementValidator = {}

function PlacementValidator.WithinBounds(_, objectSize: Vector3, worldCF: CFrame)
	-- No longer checks bounds; always returns true for now
	return true
end
function PlacementValidator.NotIntersectingObjects(_, objectSize: Vector3, worldCF: CFrame)
	-- Check if worldCF is valid (not nil)
	if not worldCF then
		warn("Received nil CFrame in NotIntersectingObjects")
		return false  -- Return false to indicate failure in intersection check
	end

	if not worldCF.Position then
		warn("Invalid Position in CFrame:", worldCF)
		return false
	end

	local parts = workspace:GetPartBoundsInBox(worldCF.Position, objectSize)


	return #parts == 0
end



return PlacementValidator

image

please can someone explain me why?

as you can see i have made “simpleCFrame” to check if its passing it to the module, but I am getting nil.

my brain stoped working from trying to understand

You should remove the first argument “_” as it recieves the value of objectSize and results in the last argument to be nil. I guess you treat “_” as self, which doesn’t get passed as the first argument if function wasn’t called with “:” instead of “.

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