Hi, I was wondering if I could Get some help on scripting support!
-
My goal is to make drifting system on my vehicle chasis!
-
Currently I’m having issues with achieving connection between player inside the vehicle and User Input Service won’t send any signals.
-
I looked some solutions on devforum, but none matched my request
A little detail, I wanted to make it so that if player is seated so that it sends a connection to a server that player is seated and if player presses LeftShift
on their keyboard, the backwheel physics start to work until the player releases LeftShift
button so it’s current properties go back to normal.
Here’s Script I made so far, It’s server script, this may look dumb but this is what I tried so far.
local driftkey = "LeftShift"
local UIS = game:GetService("UserInputService")
local Players = game:GetService("Players")
local leftwheel = script.Parent.Parent.WheelBL
local rightwheel = script.Parent.Parent.WheelBR
local trail1 = script.Parent.Trail1
local trail2 = script.Parent.Trail2
local function drift()
leftwheel.CustomPhysicalProperties.Density = 0.7
leftwheel.CustomPhysicalProperties.Elasticity = 0.5
leftwheel.CustomPhysicalProperties.ElasticityWeight = 0.1
leftwheel.CustomPhysicalProperties.Friction = 0.2
leftwheel.CustomPhysicalProperties.FrictionWeight = 0
rightwheel.CustomPhysicalProperties.Density = 0.7
rightwheel.CustomPhysicalProperties.Elasticity = 0.5
rightwheel.CustomPhysicalProperties.ElasticityWeight = 0.1
rightwheel.CustomPhysicalProperties.Friction = 0.2
rightwheel.CustomPhysicalProperties.FrictionWeight = 0
trail1.Enabled = true
trail2.Enabled = true
end
local function nodrift()
leftwheel.CustomPhysicalProperties.Density = 0.7
leftwheel.CustomPhysicalProperties.Elasticity = 0.2
leftwheel.CustomPhysicalProperties.ElasticityWeight = 1
leftwheel.CustomPhysicalProperties.Friction = 1.5
leftwheel.CustomPhysicalProperties.FrictionWeight = 1
rightwheel.CustomPhysicalProperties.Density = 0.7
rightwheel.CustomPhysicalProperties.Elasticity = 0.2
rightwheel.CustomPhysicalProperties.ElasticityWeight = 1
rightwheel.CustomPhysicalProperties.Friction = 1.5
rightwheel.CustomPhysicalProperties.FrictionWeight = 1
trail1.Enabled = false
trail2.Enabled = false
end
local seatpart = script.Parent
local isdrifting = false
if seatpart.Occupant == nil then
else
UIS.InputBegan:Connect(function(input, gameProcessedEvent)
if input.KeyCode == Enum.KeyCode[driftkey] then
end
end)
UIS.InputEnded:Connect(function(input, gameProcessedEvent)
if input.KeyCode == Enum.KeyCode[driftkey] then
print("lost")
if isdrifting == true then
print("off")
isdrifting = false
nodrift()
end
end
end)
end
I would appreciate also a little detail on where I messed up so I can learn from my mistakes to figure out next time if I encounter same problem I could avoid it.
Thank you for anyone who actually does want to help.