How to edit CustomPhysicalProperties with a script?

for _, i in pairs(q) do
	if i:IsA("BasePart") then
		i.BackSurface = Enum.SurfaceType.Weld
		i.FrontSurface = Enum.SurfaceType.Weld
		i.TopSurface = Enum.SurfaceType.Weld
		i.BottomSurface = Enum.SurfaceType.Weld
		i.LeftSurface = Enum.SurfaceType.Weld
		i.RightSurface = Enum.SurfaceType.Weld
		i:MakeJoints()
		i.CustomPhysicalProperties = true
		i.Density = 10
		i.Elasticity = 0.3
		i.Friction = 0.5
		i.FrictionWeight = 1
		i.ElasticityWeight = 1
		p = p+1
	end
end
-- it didnt work and parts are falling off :/ 
  20:02:02.784  ServerScriptService.DBAid:13: invalid argument #3 (PhysicalProperties expected, got boolean)  -  DBAid:13

any help?

1 Like

At line 13, you used a boolean instead, it expected physical properties so maybe write the physical properties instead.

Edit: Oh and i’m not talking about the code line you sent, i’m talking about the full script of “DBAid”.

still errors and the output says that “Density” is not a member of Part

Could you show the whole script?

Also, if it really is the full code, perhaps you could mess with this.

1 Like
local q = workspace.building:GetDescendants()
for _, i in pairs(q) do
	if i:IsA("BasePart") then
		i.BackSurface = Enum.SurfaceType.Weld
		i.FrontSurface = Enum.SurfaceType.Weld
		i.TopSurface = Enum.SurfaceType.Weld
		i.BottomSurface = Enum.SurfaceType.Weld
		i.LeftSurface = Enum.SurfaceType.Weld
		i.RightSurface = Enum.SurfaceType.Weld
		i:MakeJoints()
		i.CustomPhysicalProperties = true
		i.Density = 10
		i.Elasticity = 0.3
		i.Friction = 0.5
		i.FrictionWeight = 1
		i.ElasticityWeight = 1
		p = p+1
	end
end

its just welding the building with weld surfaces and I use this script because just slap in Weld on the part would not “weld” the part

Alright, density isn’t a property that could be simply changed with int64 or floats. It has to be done with physical properties, you should read this hub page and go to the properties section so you can fix this issue.

1 Like

In other cases, you could use this example to fix your code if you’re a little bit confused.

local density = .3
local friction = .1
local elasticity = 1
local frictionweight = 1
local elasticityweight = 1

local physProperties = PhysicalProperties.new(density, friction, elasticity, frictionweight, elasticityweight)

script.Parent.CustomPhysicalProperties = physProperties
17 Likes
local q = workspace.building:GetDescendants()
local d= 10
local f = .5
local e = .3
local fw = 1
local ew = 1
local pprops = PhysicalProperties.new(d,f,e,fw,ew)
for _, i in pairs(q) do
	if i:IsA("BasePart") then
		i.BackSurface = Enum.SurfaceType.Weld
		i.FrontSurface = Enum.SurfaceType.Weld
		i.TopSurface = Enum.SurfaceType.Weld
		i.BottomSurface = Enum.SurfaceType.Weld
		i.LeftSurface = Enum.SurfaceType.Weld
		i.RightSurface = Enum.SurfaceType.Weld
		i:MakeJoints()
		i.CustomPhysicalProperties = pprops		
		p = p+1
	end
end

Test it then, let’s see how it’ll go.

2 Likes