db = false
while true do
wait()
if script.Parent.Velocity.Magnitude >= 5 and db == false and script.Parent.Occupant then
local player = game.Players:GetPlayerFromCharacter(script.Parent.Occupant.Name)
if player == script.Parent.Parent.Name then
db = true
print("true")
wait(3)
db = false
end
end
end
How would I track who the occupant of the seat is I want to track it by name but I am not sure how to do this.
2 Likes
Seat.Occupant
is the humanoid sitting in the seat. It’s name would be Humanoid. game.Players:GetPlayerFromCharacter(Character)
uses the Player’s character model and not it’s name. So, to get the Character model in the seat, we use Seat.Occupant.Parent.
db = false
while true do
wait()
if script.Parent.Velocity.Magnitude >= 5 and db == false and script.Parent.Occupant then
local player = game.Players:GetPlayerFromCharacter(script.Parent.Occupant.Parent)
if player.Name == script.Parent.Parent.Name then
db = true
print("true")
wait(3)
db = false
end
end
end
Edit Oct 2nd 2023: Fixed comparison of string to player, lol. 4 years late better than never!
13 Likes
I’m pretty sure you should get the occupants Parent instead of the name, because Name is a string and the Parent of the humanoid is the character.
4 Likes