How to change the density (or mass) of an object

Issue without background info

Hello, I’m trying to set the mass of a part with as script. How do I do this? I have tried the following methods just to be met with ‘read only’ errors

Method 1: changing mass directly

local car = workspace.Car
car.Chassis.Mass = 2.51

image

Method 2: changing mass by changing density in customPhysicalProperties

local car = workspace.Car
car.Chassis.CustomPhysicalProperties.Density = 2.51

image

Notes:

  • customphysicsproperty is enabled
  • I can manually change it
    image









background info

Hello, I’m trying to make a program to quickly rig cars and I am having an issue with weight distrubution.

Because weight distribution is hard to detect in roblox, I am opting to perfectly distribute the weight of my car by making everything massless and making a single part that is the length of the car weigh a specific mass.

The issue is that I cannot change these properties through a script because I am getting an error saying read only:

  22:56:04.990  Unable to assign property Mass. Property is read only  -  Edit

and

Density cannot be assigned to
2 Likes

Nevermind I asked the roblox ai code assistant and after debugging its explanation I got this code which works:

	local car = workspace.Car
	local chassis = car.Chassis
	chassis.Massless = false	
	local currentProperties = chassis.CurrentPhysicalProperties
	local newProperties = PhysicalProperties.new(2.51, currentProperties.Friction, currentProperties.Elasticity)
	chassis.CustomPhysicalProperties = newProperties
9 Likes

Please mark your post above as the Solution so others don’t keep trying to read and solve it.
It also helps others searching for answers on the same subject by having your post marked as Solved.

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