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 :/
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.
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
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