So i want to make SetMass function but i dont know how to convert mass to density so i can get mass from part and put that mass to another part
i have made this function but its very unprecise

local Character = script.Parent
local HumanoidRootPart = Character.PrimaryPart

local function RoundFloat(Float,Precise) Precise = Precise or 1
	return tonumber(string.format("%."..Precise.."f",Float))
end

local function SetMass(Part,Mass) Mass = RoundFloat(Mass)
	local CurrentMass = RoundFloat(Part.AssemblyMass)
	local PartPhysicalProperties = PhysicalProperties.new(Part.Material)
	local Density = PartPhysicalProperties.Density
	local Volume = RoundFloat(CurrentMass / Density)
	local Volume2 = RoundFloat(Mass / Density)
	Density = RoundFloat(Mass/CurrentMass - Density,2)
	print(Density)
	
	
	Part.CustomPhysicalProperties = PhysicalProperties.new(Density,
		PartPhysicalProperties.Friction,PartPhysicalProperties.Elasticity)
	print(Part.AssemblyMass)
end

SetMass(workspace.Part,HumanoidRootPart.AssemblyMass)

2 comments

0

Density = Mass / Volume

0

Thanks! Can you post it as answer so i can check this post as answered?