Whenever the script.Parent (SeatPart) has a child added, I get the SeatPart's SeatWeld and get that weld's Part1. If that part's Parent is a character of a player, it prints "A player sat down!". Is there a better way to define the player that sat down on the part?
Here's the code:
script.Parent.ChildAdded:Connect(function(part) print("Sat down!") local part = script.Parent.SeatWeld.Part1 local plr = part.Parent if game.Players:GetPlayerFromCharacter(plr) then print("A player sat down!") end end)
You can access the player who is sitting on the seat through the Occupant value which is located inside the seat like i have done below
local Seat = script.Parent function SitDetection(Child) if Child.Name == "SeatWeld" then local Character = Seat.Occupant.Parent local Player = game.Players:GetPlayerFromCharacter(Character) print(Player.Name) print(Character.Name) end end Seat.ChildAdded:Connect(SitDetection)