Cannot seem to figure out Physical propperties

  1. What do you want to achieve?
    I want to change the friction on the Tires of my car when Left Shift is being held.

  2. What is the issue?
    I cannot seem to figure out how to change the friction and friction weight the values are always wrong.


    image

  3. What solutions have you tried so far?
    I’ve tried to look at the developer hub and in-studio help.

Any responses are appreciated!

local script:

local car = script.Parent:WaitForChild("Car").Value
local Seat = car.Body.VehicleSeat

local remoteEvent = car.CarHandler.functions.ChangeFriction

local uis = game:GetService("UserInputService")


uis.InputEnded:connect(function(input)
	if input.KeyCode == Enum.KeyCode.LeftShift then
		print("back to norm")
		remoteEvent:FireServer(0.8, 10)
	end
end)

uis.InputBegan:connect(function(input)
	if input.KeyCode == Enum.KeyCode.LeftShift then 
		print("fired")
		remoteEvent:FireServer(0.3, 1)
	end
end)

server script:

local RemoteEvent = script.ChangeFriction

RemoteEvent.OnServerEvent:Connect(function(f, fw)
	local density = .7
	local friction = f
	local elasticity = .5
	local frictionWeight = fw
	local elasticityWeight = 1
	local physProperties = PhysicalProperties.new(density, friction, elasticity, frictionWeight, elasticityWeight)
	script.Parent.Parent.Body.WheelFL.PhysicalWheel.CustomPhysicalProperties = physProperties
	script.Parent.Parent.Body.WheelFR.PhysicalWheel.CustomPhysicalProperties = physProperties
	script.Parent.Parent.Body.WheelRL.PhysicalWheel.CustomPhysicalProperties = physProperties
	script.Parent.Parent.Body.WheelRR.PhysicalWheel.CustomPhysicalProperties = physProperties
end)

Again any responses are appreciated!

OnServerEvent always has the player who fired the event as the first parameter, so you may have to change it to this

RemoteEvent.OnServerEvent:Connect(function(player, f, fw)

So it properly reads your 2 values

1 Like

Wow, what a rookie mistake of me! Thanks for correcting me…

1 Like

That is completely okay, mistakes how are you learn in the first place!!

If you have anymore issues don’t be afraid to make another post!