[SOLVED] How to Detect if the Player is sitting in any way

I have a Gui that allows you to teleport to any Metro Station you want, but if you teleport to a Metro Station whilst sitting down (inside a train), the trains comes with you. Which then brakes the game.

Any way to detect if the player is sitting on any seat, then if the player attempts to teleport the Player can’t and it instead prints out an Error Message?

Here is a link to a video as an example:

(sorry for the deleted one, I fixed it)

1 Like

Many ways:

-Check if sit proprety of Humanoid is True
-Check occupant of seat part
-Check using Seated event on humanoid

by the way the video u sent is deleted

(post edited, change is Seating → Seated, appologies for misspell)

3 Likes

Can you please give me an example?

1 Like

Of course!

Sit proprety:

local player = game.Players.LocalPlayer
local char = player.Character or player.CharacterAdded:Wait()

local hum = char:WaitForChild("Humanoid")

hum:GetPropretyChangedSignal("Sit"):Connect(function()
	if hum.Sit == true the
		--function
	end
end)

Occupant:

local Seat =  script.Parent -- Path to seat

Seat:GetPropertyChangedSignal("Occupant"):Connect(function()
	if Seat.Occupant ~= nil then
		local Char = Seat.Occupant.Parent
		--function
	end
end)

Seated:

local player = game.Players.LocalPlayer
local char = player.Character or player.CharacterAdded:Wait()

local hum = char:WaitForChild("Humanoid")

hum.Seated:Connect(function()
	--function yipee
end)
1 Like

Works like I wanted it to, thank you!

(I used if hum.Seated)

1 Like

oo forgot to mention, first and last scripts are local

2 Likes

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.