Detect when a player sits in a chair

I tried writing a code that detects when a player sits in a chair but It doesn’t work no sign of errors I tried using print but no print in console too can someone help me?

My code is a local script

local cam = workspace.CurrentCamera
local Seat = script.Parent.Koltuklar.Chair1.Seat

local function oturma()
	if Seat.Occupant ~= nil and cam.CameraType == Enum.CameraType.Custom then
		print('Biri oturdu')
		cam.CameraType = Enum.CameraType.Scriptable
	elseif Seat.Occupant == nil and cam.CameraType == Enum.CameraType.Scriptable then
		print('Kişi şuan oturmuyor')
		cam.CameraType = Enum.CameraType.Custom
	end	
end

cam.CameraType = Enum.CameraType.Scriptable

Seat:GetPropertyChangedSignal("Occupant"):Connect(oturma)

Thanks.

1 Like

Hello!

Is this a local script?

yes it is a local script should it be a normal script?

If this script is in Workspace, it won’t work. Try putting it into StarterPlayerScripts.

okay will try it now my friend says that I can also use a remote event?

No need for making algorithms for seat, there is already a built in Humanoid that contains a bool value called ”Sit” to know if Humanoid is sitting and a reference to that seat ”SeatPart” read more here: https://create.roblox.com/docs/reference/engine/classes/Humanoid#SeatPart

I need to check if a player is sitting in a SPECIFIC chair tho not just sitting

It worked by the way thank you for your support

1 Like

Your are still able to use the ”SeatPart” property combined with a if statement

Your welcome!

Have a nice time!

1 Like

or put a script into the seat and put the run context to client instead

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