I need help fixing the seat exit script

  1. What do you want to achieve?
    Whenever the detection part hits an entity (like a wall or piece of terrain), the player exits in a different direction since you can’t disable jumping using a normal script

  2. What is the issue?
    -This error:


    -It breaks whenever there are 2 or more people inside the same vehicle

  3. What solutions have you tried so far?
    -I checked out the cars made by roblox, but I noticed that they used LocalScripts to do them

The lines that exit the player:

local formerOccupant

seat:GetPropertyChangedSignal("Occupant"):Connect(function()
	local hum = seat.Occupant
	
	if hum then
		formerOccupant = hum.Parent
	else
		wait()
		formerOccupant.HumanoidRootPart.CFrame = seat.CFrame + (seat.CFrame.RightVector * -5)
		formerOccupant = nil
	end
end)

seat.Touched:Connect(function()
	seat:GetPropertyChangedSignal("Occupant"):Connect(function()
		local hum = seat.Occupant

		if hum then
			formerOccupant = hum.Parent
		else
			wait()
			formerOccupant.HumanoidRootPart.CFrame = seat.CFrame + (seat.CFrame.UpVector * 5)
			formerOccupant = nil
		end
	end)
end)

seat.TouchEnded:Connect(function()
	seat:GetPropertyChangedSignal("Occupant"):Connect(function()
		local hum = seat.Occupant

		if hum then
			formerOccupant = hum.Parent
		else
			wait()
			formerOccupant.HumanoidRootPart.CFrame = seat.CFrame + (seat.CFrame.RightVector * -5)
			formerOccupant = nil
		end
	end)
end)
2 Likes

I dont know if thisll help but maybe try teleporting the player instead?

What I’m trying to do here is to prevent the player from glitching through entities detected by the detection part whenever you exit the vehicle.

1 Like

Well then you can find a way to teleport the player to the opposite position of the entity, sorry im not a good scripter

That’s what I’m trying to do here, but the problem is that the script gave me an error then it decides to break out of the blue

1 Like

Well maybe try putting it into a local script that every seat has, or find a way to make one script control all of them. I dont really understand your script as i have just woken up so im sorry if im not helping

That’s ok… But doing a localscript on a seat seems too hard for me because you have to make a GUI then script it to go to the occupant’s StarterGui then make a value to make the occupant’s car as it’s child (kinda like A-Chassis, I tried to copy the thing A-Chassis did, but the code was spaghetti that it gave me a headache), but if I were able to do that, I wouldn’t have made this topic since you can disable jumping using localscripts.

You could just change the localplayers gravity or jump power

If I do that using a ServerScript (normal script), it affects the other players who aren’t even the occupants of the seat.

2 Likes

And thats why I said to use a local script. but if it still doesnt work then i dont know what will.

I know localscripts can work, but like what I told you, it’s too hard to do because I have to script parts that I don’t even know how to do, that’s why I made this topic for guidance.

1 Like

Well then I sadly cant help you. I tried, sorry.

1 Like

that’s ok, at least you tried to help me

1 Like