Unable to Assign property, got table

I’m trying to utilize a modular script to produce constraint objects, and am trying to pass Attachment points and the parent to the module via a server script.
Upon using the function, I receive this error:

This is the offending function in the module:

function AITConstraintModule.GenerateAlignment(Attach1,Attach2,Parent)
	local Align = Instance.new("AlignOrientation")
	Align.Mode = Enum.OrientationAlignmentMode.TwoAttachment
	Align.AlignType = Enum.AlignType.Parallel
	Align.PrimaryAxisOnly = false
	Align.ReactionTorqueEnabled = true
	Align.RigidityEnabled = true
	Align.Responsiveness = 30
	Align.Parent = Parent
	Align.Attachment0 = Attach1
	Align.Attachment1 = Attach2

And in the script calling GenerateAlignment()

local function GenerateTraffic()
	local ClonedVehicle = RandomVehicleSelection:Clone()
	ClonedVehicle.Name = "AIVehicle"
	local CVehicleAttachment = ClonedVehicle.Attachment
	local LaneAttachment = RandomLaneSelection.Attachment
	ClonedVehicle.CFrame = CFrame.new(LanePosition)
	ClonedVehicle.Parent = TrafficFolder
	PhysicsService:SetPartCollisionGroup(ClonedVehicle, "RaceCars")
	ClonedVehicle.LinearVelocity.MaxForce = 100000
	if RandomLaneSelection.Name == "Pass" then
		ClonedVehicle.LinearVelocity.LineVelocity = 85
		ClonedVehicle.LinearVelocity.LineVelocity = 70
	ClonedVehicle.Rev.PlaybackSpeed = random:NextNumber(0.6,0.9)
	ClonedVehicle.LinearVelocity.Enabled = true

ClonedVehicle.Attachment and RandomLaneSelection.Attachment both exist, and ClonedVehicle refers to a car that has been duplicated and placed into a specific folder in Workspace. The code inside the GenerateAlignment function has simply just been moved out of the server script and placed into a module format. This did work as intended in its original format, but I wanted to pretty GenerateTraffic() up a little while also utilizing this constraint generator elsewhere.
I don’t understand where the module is finding a table, though.
Any help is appreciated.

1 Like

You used a Dot for the Function but instead used Colon when using the function.

The difference between these two, as much as I know: If you made a function with Dot but used it with Colon, the first argument will be “self,” which refers to the “AITConstraintModule” table instead of Attach1.

E.G. Object.FindFirstChild(Object, "thing"), you’ll have to send Object as first argument, but colon make it so it sends itself first, Object:FindFirstChild("thing"). You can try learning more about these by searching but this is as much as I know how to explain. I hope I am correct because I am not fluent in scripting with these yet.

1 Like

Yeah I just saw that, it’s 3:41 AM lmao

Thanks for the reply.

1 Like