Tweening Physics Properties of a Part

I’m trying to figure out how or if you can tween the PhysicsProperties of a part (Density, Friction etc)

But I can’t seem to figure out how to achieve this with TweenService if you even can do this.
Here is what I tried to do and it didn’t work.

game:GetService("TweenService"):Create(workspace.Part,TweenInfo.new(1),{CustomPhysicalProperties=PhysicalProperties.new(100, 0.48, 0.2, 1, 1)}):Play()

Why are you trying to tween that? Just set the Properties to the values you want. They aren’t a visible property so why try to make it a smooth transition?

There is a way to do this not sure why you would want to but you can setup 5 number values in this case I will name them 1-5 also. then you set them to the default/starting values of your PhysicalProperties! then you make sure to connect a change function on the last value when it changes in that function you want to set your parts properties with the values as i have done below also there is an image showing how to setup the folder just make sure the values are added in order for iteration

-- Make sure you add the numbervalues to the folder in order since the tables is referenced and ipairs are in order

local defaults = {0, 0, 0, 0, 0}  -- using 0 on all defautl so i can see them tween to number
local numbervalues = script.Parent.NumbersFolder:GetChildren()  -- get all the values from folder
local ValuesToTweenTo = {100, 0.48, 0.2, 1, 1}  -- using 0 on all defautl so i can see them tween to number

for i, number in ipairs(numbervalues) do  -- go through and setup the defaults and change function on last
	number.Value = defaults[tonumber(number.Name)] -- set the default
	if number.Name == '5' then
		
		number.Changed:Connect(function()  -- when the last value changes update the properties of the part
			print('Changing')
			print(numbervalues[1].Value,numbervalues[2].Value , numbervalues[3].Value, numbervalues[4].Value, numbervalues[5].Value)
			workspace.Part.CustomPhysicalProperties = PhysicalProperties.new(numbervalues[1].Value,numbervalues[2].Value , numbervalues[3].Value, numbervalues[4].Value, numbervalues[5].Value)
		end)
		
	end
end
wait(8)
for i, number in ipairs(numbervalues) do  -- this goes through and tweens each value 5 should be last if you added it last to folder
	print(number)
	game:GetService("TweenService"):Create(number,TweenInfo.new(1),{Value = ValuesToTweenTo[i]}):Play()
end

e3a76dae9e88c263b50baeaed279bbdb

It’d be better to use a loop, you can also mimic the tween that you desire in various ways. It’s best to use a loop instead.

It was because I wanted to create the effects of objects slowly becoming more slippery or an object gaining weight overtime rather than all at once without changing any visual properties of the object.

2 Likes

Ok cool that should work if you have trouble with one of the variables not going to the max like your 100 then switch the change function to the highest value the tween sometimes takes just a fraction longer to finish it so it would set your max numbers for sure