Find out what seat the player is sitting on

Hello,

What I want to achieve is that when a player triggers a ProximityPrompt, it will check if the player is sitting, and if yes, it will return the seat in which the player is.

Currently, my script is that :

local ProximityPromptService = game:GetService("ProximityPromptService")


local function onPromptTriggered(promptObject, player)

	if promptObject.Parent.Name == "ThatPart" then
		if player.Character.Humanoid.Sit == true then
			local CurrentSeat -- Here I need to get the seat the player is in
			if CurrentSeat.Parent.Name == "TheThingIwant" then
				-- Do Things
			end
		end
	end
end

ProximityPromptService.PromptTriggered:Connect(onPromptTriggered)

If you know how to do this or there is a existing topic that can help, please tell me !

2 Likes

There’s a property for the Humanoid called SeatPart. You can use that

local CurrentSeat = player.Character.Humanoid.SeatPart
9 Likes
local ProximityPromptService = game:GetService("ProximityPromptService")

local function onSeated(isSeated, seat)
	if isSeated then
		print(seat.Name)
	else
		print("I'm not sitting on anything")
	end
end

local function onPromptTriggered(promptObject, player)
	if promptObject.Parent.Name == "ThatPart" then
      humanoid.Seated:Connect(onSeated)
	end
end

ProximityPromptService.PromptTriggered:Connect(onPromptTriggered)
1 Like

I didn’t know this property, thank you !

1 Like

Anytime! If you have anymore issues don’t be afraid to make another post!

3 Likes