Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Change CustomPhysicalProperties without error?

I keep getting an error when trying to change the density of a part through a script:

local children = game.Workspace.Model:GetChildren()
for i = 1, #children do
    while true do
		wait(1.2)
		children[i].CustomPhysicalProperties.Density = children[i].CustomPhysicalProperties.Density + 0.05
	end
end

Error: PhysicalProperties.Density cannot be assigned to Script 'Workspace.Script', Line 5

What do I do here I'm confused?

1 answer

You have to make a new CustomPhysicalProperties object. Things like Vector3 and CustomPhysicalProperties don't know where they came from, and therefore it is pointless to be able to set the values - As a result, they are read-only, and you'll have to construct a new one every time.

This discussion is preserved as it was. New answers, comments, and votes are closed.