Hello! I am trying to find out when a vehicle seat obtains an occupant and then want to get that players mouse. I am not sure on how to do this, but I did try this:
local occupant = script.Parent.Occupant
local mouse = game.Players:GetPlayerFromCharacter(occupant)
while true do
wait()
if occupant ~= nil then
print(occupant.Name)
end
end
What @Aeventy said is correct, and also, to just detect the occupant of the set you can use GetPropertyChangedSignal on the Occupant property
local seat = script.Parent
seat:GetPropertyChangedSignal("Occupant"):Connect(function()
local hum = seat.Occupant
if not hum then return end
local plr = game.Players:GetPlayerFromCharacter(hum.Parent)
if not plr then return end
print(plr.Name)
end)