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

How to make friction change each time something is touched?

I'm wondering if there's any way to make the friction of a brick change by a certain amount each time it is touched. Any help would be appreciated. Thanks!

1 answer

✓ Accepted answer

The code is quite simple. Put it inside of the part you desire.

--Reset friction after a set amount of time (debounced)
debounce = false

script.Parent.Touched:connect(function()
	if debounce == true then return end
	debounce = true
	local formerfriction = script.Parent.CustomPhysicalProperties.Friction
	script.Parent.CustomPhysicalProperties.Friction = 1 --Change to what you desire
	--Remove this part below if you don't want it to reset, but don't remove the end)
	wait(5) --Change to what you desire
	script.Parent.CustomPhysicalProperties.Friction = formerfriction
	debounce = false
end)

--Set friction as long as the part is being stepped on/touched
local OffFriction = 0.3
local OnFriction = 1

script.Parent.Touched:connect(function()
	script.Parent.CustomPhysicalProperties.Friction = OnFriction
end)

script.Parent.TouchEnded:connect(function()
	script.Parent.CustomPhysicalProperties.Friction = OffFriction
end)

1 comment

0

Sorry for being so late, but thank you so much! Have a great day!

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