Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

How to make script discriminate between VehicleSeats & normal Seats?

Asked by 3 years ago

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

Log in to vote
3
Answered by
Raccoonyz 1092 Donator Moderation Voter
3 years ago

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.

0
very well done thank you arjun9022 34 — 3y
Ad

Answer this question