"Unable to assign property CustomPhysicalProperties. PhysicalProperties expected, got table"

I get an error:
Unable to assign property CustomPhysicalProperties. PhysicalProperties expected, got table
The error is located in line 26.

Here’s the script line:

Door1.DoorPart.CustomPhysicalProperties = moduleData.secondModuleData.setPhysicalProporties

The module script:

local density = 0.01
local elasticity = 0.25
local elasticityWeight = 1
local friction = 0.4
local frictionWeight = 1

local Module = {}

Module.firstModuleData = {
	tweenInfo1 = TweenInfo.new(
		1,
		Enum.EasingStyle.Sine,
		Enum.EasingDirection.InOut,
		0,
		false,
		0
	)
}

Module.secondModuleData = {
	setPhysicalProporties = PhysicalProperties.new(
		density,
	    elasticity,
	    elasticityWeight,
	    friction,
	    frictionWeight
    )
	
}

Module.thirdModuleData = {
	tweenInfo2 = TweenInfo.new(
		0.1,
		Enum.EasingStyle.Sine,
		Enum.EasingDirection.InOut,
		0,
		false,
		0
	)
}

return Module

Any help is appreciated, thanks.

1 Like

Hi!

Unable to assign property CustomPhysicalProperties. PhysicalProperties expected, got table cannot be related to the exact code you appended, unless not the same module is required or the module is modified. I tested it, and the only issue is physical properties’ order inside the constructor. The proper argument order is

setPhysicalProporties = PhysicalProperties.new(
	density,
	friction,
	elasticity,
	frictionWeight,
	elasticityWeight
)

@1IsTech could you please provide more information on how you require the module, code snippets with more context and so on?

1 Like

It still don’t work, the output keeps saying the same error.

1 Like

The main script:

local TweenService = game:GetService("TweenService")
local Door1 = script.Parent:WaitForChild("Door1")
local Door2 = script.Parent:WaitForChild("Door2")
local GlassDoorConfigures = script.Parent:WaitForChild("GlassDoorConfigures")
local Touch = script.Parent:WaitForChild("Touch")
local moduleData = require(script.Parent.ModuleData)
local debounce = false

GlassDoorConfigures.CanShatter:GetPropertyChangedSignal("Value"):Connect(function()
	if GlassDoorConfigures.CanShatter.Value == true then
		GlassDoorConfigures.ShatterChance.Value = math.random(1, 10)
	elseif GlassDoorConfigures.CanShatter.Value == false then
		GlassDoorConfigures.ShatterChance.Value = 0
	end
end)
Touch.Touched:Connect(function()
	if debounce == false and GlassDoorConfigures.ShatterChance.Value < 9 then
		debounce = true
		TweenService:Create(Door1.DoorPart, moduleData.firstModuleData.tweenInfo1, {CFrame = script.Parent.OpenDoor1.CFrame}):Play()
		TweenService:Create(Door2.DoorPart, moduleData.firstModuleData.tweenInfo1, {CFrame = script.Parent.OpenDoor2.CFrame}):Play()
	elseif debounce == false and GlassDoorConfigures.ShatterChance.Value > 9 then
		debounce = true
		TweenService:Create(Door1.DoorPart, moduleData.thirdModuleData.tweenInfo2, {CFrame = script.Parent.ShatterDoor1.CFrame}):Play()
		TweenService:Create(Door2.DoorPart, moduleData.thirdModuleData.tweenInfo2, {CFrame = script.Parent.ShatterDoor2.CFrame}):Play()
		wait(0.1)
		Door1.DoorPart.CustomPhysicalProperties = moduleData.secondModuleData.setPhysicalProporties
		Door2.DoorPart.CustomPhysicalProperties = moduleData.secondModuleData.setPhysicalProporties
		Door1.DoorPart.Anchored = false
		Door2.DoorPart.Anchored = false
	end
end)
Touch.TouchEnded:Connect(function()
	if debounce == true and GlassDoorConfigures.ShatterChance.Value < 9 then
		debounce = false
		TweenService:Create(Door1.DoorPart, moduleData.firstModuleData.tweenInfo1, {CFrame = script.Parent.CloseDoor1.CFrame}):Play()
		TweenService:Create(Door2.DoorPart, moduleData.firstModuleData.tweenInfo1, {CFrame = script.Parent.CloseDoor2.CFrame}):Play()
	end
end)

The module script:

local density = 0.01
local elasticity = 0.25
local elasticityWeight = 1
local friction = 0.4
local frictionWeight = 1

local Module = {}

Module.firstModuleData = {
	tweenInfo1 = TweenInfo.new(
		1,
		Enum.EasingStyle.Sine,
		Enum.EasingDirection.InOut,
		0,
		false,
		0
	)
}

Module.secondModuleData = {
	setPhysicalProporties = PhysicalProperties.new(
		density,
		friction,
		elasticity,
		frictionWeight,
		elasticityWeight
	)
	
}

Module.thirdModuleData = {
	tweenInfo2 = TweenInfo.new(
		0.1,
		Enum.EasingStyle.Sine,
		Enum.EasingDirection.InOut,
		0,
		false,
		0
	)
}

return Module

Strange indeed. I don’t see anything affecting secondModuleData. There are some other minor improvement you can make, but CustomPhysicalProperties is not one of them. :thinking:

Are you sure the ModuleData is not some other version of your module?

Because the error says you’re providing table and not PhysicalProperties, we know that the required module does have a table stored inside setPhysicalProporties, which is nested inside Module.secondModuleData.

print(typeof(Module.secondModuleData.setPhysicalProporties)) -- may help

By the way, you should create your tweens once and solely play them inside the function; use task.wait() in place of old wait(), and there’s a small typo (it’s properties, not proporties).

1 Like

Of course, the moduleData is not the other version of my module,
but the output keeps saying the same error again and again.

1 Like

It’s a sliding door script, and i don’t know what this problem is.

1 Like

I fixed the problem, I sended you the wrong script, sorry for that, I didn’t add setPhysicalProperties to CustomPhysicalPhysicalProporties.

2 Likes

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