You can write your topic however you want, but you need to answer these questions:
**What do you want to achieve? I want to detect when players are sitting so i can open a UI when they sit
What is the issue? Include screenshots / videos if possible! I used a .Touched Event and it’s only working for standing on the seat not sitting. i got a problem where my sit script is not printing but when i touch it the seat prints. i want the event to fire when i sit not touch it
What solutions have you tried so far? Did you look for solutions on the Developer Hub?
None
After that, you should include more details if you have any. Try to make your topic as descriptive as possible, so that it’s easier for people to help you!
Hello, so i’m making a script that automatically opens a Gui when the players sit on the chair., but my problem is why is it not working. I used a .Touched Event.
Humanoid.Sit returns a boolean that determines if the humanoid is currently sitting Humanoid.SeatPart returns the part the humanoid is currently sitting on, or nil.
forgot to add that seats also have a Seat.Occupant property
local seat = script.Parent
seat:GetPropertyChangedSignal("Occupant"):Connect(function()
if seat.Occupant ~= nil then
--: local plr = game:GetService("Players"):GetPlayerFromCharacter(seat.Occupant.Parent) -- optional if you want the player
--: rest of code here
end
end)
local players = game:GetService("Players")
local player = players.LocalPlayer
local character = player.Character or player.CharacterAdded:Wait()
local humanoid = character:WaitForChild("Humanoid")
humanoid.Seated:Connect(function(isSeated, seatPart)
if isSeated then
print(seatPart.Name)
else
print("Player is no longer seated!")
end
end)
The Humanoid.Seated event is the correct way to go about achieving this.