I’m trying to get the player of the person that sat down in the seat but it’s not working correctly
code:
script.Parent.ChildAdded:Connect(function()
local player = game.Players:FindFirstChild(script.Parent.SeatWeld.Part1.Parent.Name)
print(player.Name)
end)
You could check whenever the “Occupant” property of the seat is changed through GetPropertyChangedSignal.
local seat = script.Parent -- assuming
seat:GetPropertyChangedSignal("Occupant"):Connect(function()
local human = seat.Occupant
if human then
local player = Players:GetPlayerFromCharacter(human.Parent) -- actual player
if player then -- might fire for NPCs I believe, so check if this is a player's humanoid
print(player.Name)
end
end
end)