Friction change in car drift system not functioning properly

Goal

I am trying to make it so holding shift causes the car to drift. I am doing this by simply lowering the friction of each wheel (in this case a sphere) when shift is held. The default friction is 2 and holding shift sets it to .2. Here is the relevant code for this (in a localscript, the player’s character is a car):

local function onUpdate(delta)
	if player.Character then

		if drifting then
			for _, wheel in ipairs(player.Character.Wheels:GetChildren()) do
				wheel.Friction = .2
			end
		else
			for _, wheel in ipairs(player.Character.Wheels:GetChildren()) do
				wheel.Friction = 2
			end
		end

	end

end

(It correctly detects if it is drifting or not, I tested that earlier with a print statement)

The problem

There is no difference made when I hold shift. In the server side, I see .7 no matter what (that’s what it’s set to in studio before the simulation is run). I try printing the value of one of the wheels, but weirdly enough, it prints .3 repeatedly:

while true do
	wait(1)
	print(script.Parent.Wheels.fl.Friction) -- .3 no matter what
end

Network ownership is set manually on the car, I even tried setting it on all of the wheels to just to be redundant. Does this have to do with the fact that it’s being set in a localscript? I’d prefer the drifting to be client side so there’s little to no input lag.

2 Likes

I found the issue. Friction is deprecated, but you can do what it says here: How to edit CustomPhysicalProperties with a script? - #8 by reygenne1

Creating a new physical properties object and setting it that way works for me.

2 Likes

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.