I am trying to get the Humanoids Parents Name in the Following segment of code But it only gives me the error "attempt to index nil with 'Parent'" when i get up from the seat
Seat:GetPropertyChangedSignal("Occupant"):Connect(function() humanoid = Seat.Occupant Character = humanoid.Parent end)
(humanoid and Character were declared previously)
Thanks in Advance! This forum has been very helpful!
I think it's because when you get up from the seat, Seat.Occupant
becomes nil
. Which means, there is no one on the seat. And obviously, nil
has no parent or anything. Maybe you can do this instead:
Seat:GetPropertyChangedSignal("Occupant"):Connect(function(property) if property == nil then return end --checks if property is nil and basically stops the script if so. so it wouldnt error out humanoid = Seat.Occupant Character = humanoid.Parent end)
Hope this helps!