Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Need help making a button that changes part density?

Asked by 4 years ago
Edited 4 years ago

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

Log in to vote
0
Answered by 4 years ago
Edited 4 years ago

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

Ad

Answer this question