#how do i know if player exited seat willingly or because of death?
22 messages · Page 1 of 1 (latest)
** You are now Level 1! **
because if you're not then i know a workaround
local character = game.Players:GetPlayerFromCharacter(character).Character
you get the player from the character using the players' :GetPlayerFromCharacter function, then you get the character from that player
you could always use userinputservice instead 💀
mk
Well when you have the occupant humanoid you can check for the died event ?
local seat = ...
local function OnSeat()
...
seat.Occupant.Died:Connect(function()
...
end)
end
seat:GetPropertyChangedSignal("Occupant"):Connect(OnSeat)
Oohhh I understand
Well use :Wait() instead of connecting
seat:GetPropertyChangedSignal("Occupant"):Wait()
seat.Occupant.Died:Wait()
Or disconnects the OnSeat event
Well does this helps you
local connection = ...
local function OnSeat()
...
connection:Disconnect()
end
connection = seat...:Connect(OnSeat) -- Changed
And then reconnect when he dies
You're right then just make a condition ?
local oldOccupant = nil
local function OnSeat()
if seat.Occupant == nil and oldOccupant and oldOccupant.Health <= 0 then
print("He died")
oldOccupant= nil
return
end
if seat.Occupant and not oldOccupant then
print("Someone just seat")
oldOccupant= seat.Occupant
end
print("He just left")
oldOccupant= nil
end
Wdym
I understand
Well I need to unit test it but rn I take a shit lol
Yes but I find this ugly tho