-
What do you want to achieve?
I want to change the friction on the Tires of my car when Left Shift is being held. -
What is the issue?
I cannot seem to figure out how to change the friction and friction weight the values are always wrong.
-
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!