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

How do make a script detect when [player] is sitting?

Asked by 5 years ago

I want to make a script that puts my camera on a certain part when sitting (for a vehicle) but don't know how to type it out / execute it.

1 answer

Log in to vote
0
Answered by
royaltoe 5144 Moderation Voter Community Moderator
5 years ago

You can use the humanoid's Seated property

Put the following code in a LocalScript inside Explorer Tab->StarterPlayer->StarterPlayerScripts.

01local character = script.Parent
02local humanoid = character:WaitForChild("Humanoid")
03 
04--this is an event that is called every time the player's Seated property changes
05humanoid.Seated:Connect(function(isSeated, seat)
06    if isSeated then
07        if seat then
08            print ("The player is now sitting in the seat named "..seat.Name.."!")
09        end
10    else
11        print("The player is no longer sitting!")
12    end
13end)
0
thanks man very appreciated speedyfox66 237 — 5y
Ad

Answer this question