Heyya, I’m trying to make a simple code that detects if the car crashed using the Touched function and then ejects the player from the seat. The problem I have is after the script ejects the player, the player’s walking seems wonky and weird.
I’m trying to make it so that after the eject, the player’s walking doesn’t slide and there is where I’m asking for help.
I’ve tried looking through some old bug reports and scripting support here in the devforum but I didn’t find or missed the solution to my problem.
local speed = 0
local isDamaged = false
local P = script.Parent.Parent.Parent.Parent.DriveSeat
script.Parent.Touched:Connect(function()
if isDamaged == false then
speed = script.Parent.Velocity.Magnitude
print(speed)
wait()
if speed > 100 then
isDamaged = true
script.Parent.Parent.CrashSmoke.Fire.Enabled = true
script.Parent.Parent.CrashSmoke.Smoke.Enabled = true
script.Parent.Parent.Parent.Parent["A-Chassis Tune"].Initialize.Disabled = true
wait(2)
local occupant = P.Occupant
if occupant ~= nil then
occupant.Sit = false
end
elseif speed > 70 and speed < 100 then
isDamaged = true
script.Parent.Parent.CrashSmoke.Smoke.Enabled = true
script.Parent.Parent.Parent.Parent["A-Chassis Tune"].Initialize.Disabled = true
wait(2)
local occupant = P.Occupant
if occupant ~= nil then
occupant.Sit = false
end
end
end
end)
I haven’t really optimized the code yet since I’m still trying to finalize and fix the problems I’m encountering.
Thanks for your time and I hope there’s a simple solution to this.
this happens to quite alot of people I know, I don’t know why this happens but a way to fix it is by making the players sit variable false BEFORE you disable any scripts or destroy any seats.
Just guessing.
I know that when I’ve had vehicles that I’ve Anchored the VehicleSeat after a player jumps out of the seat it makes the vehicle Parts act like conveyors because the Parts that are welded to the Anchored seat have the value in the BasePart | Roblox Creator Documentation set at some random value it and looks a lot like what’s happening in the video.
I’m assuming you’re using A-Chassis here right? I know because I work with it for buses. When a player sits in the seats of an A-Chassis vehicle. A bit of code in the core chassis script removes the mass from the player. Then when you jump out normally it restores it. But when that seat is deleted/SeatWeld. The script doesn’t have time to restore your mass resulting in you being that light that you slide about. At least that’s my theory. This is from my own visual observations.
The script doesn’t delete the Seat or the SeatWeld of the character as it only ejects the player using occupant.Sit = false. I also have tried using occupant.Jump = true to no avail.
If it is the script removing the mass from the player, is it possible to manually add it back?