CFrame value being turned into a table when passed to a ModuleScript

I’m trying to send this CFrame value from a ServerScript to a ModuleScript function I have in ServerStorage.

--in ServerScript, calling the function in the ModuleScript
local cf = anothercf:ToWorldSpace(,0,-4.5))

local returndata = module:MakePart(cf)

However, the ModuleScript throws an error when I try to use the value to set the CFrame of a part, saying “(CFrame expected, got table)”

--in ModuleScript
function module.MakePart(cf)
	local part ="Part", workspace)
	part.Name = "Box"
	part.Size =,9,9)
	part.Locked = true
	part.Anchored = true
	part.CanCollide = false
	part.Transparency = 0.5
	part.CFrame = cf --throws error at this line

I tried using the CFrame value in the same ServerScript and it worked.

local cf = anothercf:ToWorldSpace(,0,-4.5))

local testpart ="Part", workspace)
testpart.CFrame = cf 

local returndata = module:MakePart(cf)

The part was created and positioned at that CFrame.
So I’m thinking it’s some behaviour of ModuleScripts that I don’t understand.

I believe the issue is caused by the : which causes the function to return self which is the module table instead of CFrame into the first argument.

Try doing dot notation instead:

local returndata = module.MakePart(cf)

From methods in this article.

1 Like