- So, i was doing some coding then i realize :
-- Get a reference to the seat
local seat = script.Parent -- Assuming the script is inside the seat
-- Get the Players service
local Players = game:GetService("Players")
-- Listen for changes to the Occupant property
seat:GetPropertyChangedSignal("Occupant"):Connect(function()
-- Check if the seat is now empty
if seat.Occupant == nil then
-- Get the player who left the seat (if there was one)
local previousOccupant = seat.Occupant
if previousOccupant then
local player = Players:GetPlayerFromCharacter(previousOccupant.Parent)
if player then
print(player.Name .. " left the seat.")
-- Add your code here to handle the player leaving the seat
end
end
end
end)
this is the code i found online to find the player who left the seat, but then i realize, hey how can this script get the player if the humanoid is not there anymore. AFterward, my mind ask, how do i make a script that find the player who left the seat. I search everywhere, but nothing. I try to play it but what it printed is nothing
So , anyone can help me?