Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

How to make script discriminate between VehicleSeats & normal Seats?

As the title says I am basically writing a first-person-camera script that should only activate when in a vehicle seats instead of a regular seat. I am doing this because I don't want players sitting in a café chair to be forced into first person, only when they are driving and are the designated driver because I have guns that lets players do drive-bys but they get broken with this camera script.

The method that the script uses to detect player sitting is using character states i.e. platform stand, sitting, running, etc which is ineffective at separating VehicleSeats from regular seats.

That section of code looks like this:


char:WaitForChild("Humanoid").Changed:connect(function(val)
	if (val == "Sit" and char.Humanoid.Sit == true) or (val == "PlatformStand" and char.Humanoid.PlatformStand == true) then
		seatCam()
	end
end)

It's really easy to make a general detection for playerstates like sitting but it does not help me separate VehicleSeats from regular seats. So how would I go about checking if the player is in a certain type of seat?

Thanks.

1 answer

✓ Accepted answer

Humanoids have a SeatPart property that you can use to detect the seat the player is in. You can then check the ClassName property of that seat to see if it's a vehicle seat.

1 comment

0

very well done thank you

This discussion is preserved as it was. New answers, comments, and votes are closed.