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

Need help making a button that changes part density?

Hello so Im trying to make a button that changes the density of a part so that it will sink. Im doing this for my sub game. How should the scrip look like? I would be really grateful if someone could help me. thank you

1 answer

✓ Accepted answer

You can modify density with CustomPhysicalProperties

local density = .3
local friction = .1
local elasticity = 1
local frictionWeight = 1
local elasticityWeight = 1

local function sink()
    local part = script.Parent
    local physProperties = PhysicalProperties.new(density, friction, elasticity, frictionWeight, elasticityWeight)
    part.CustomPhysicalProperties = physProperties
end

All you would need to do is change settings at top and connect sink() to the GUI button down event

I got this from wiki: https://developer.roblox.com/en-us/api-reference/property/BasePart/CustomPhysicalProperties

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