Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Is it possible to find the Player who is in a vehicle seat?

Asked by 9 years ago

Is it possible to find the Player who is driving a car or sitting in a vehicle seat? If so is it possible to activate a GUI for that person? This is not a request, i am not asking for a script, just asking whether or not it is possible I though FindFirstChild might work, but then I realized there would be a humanoidrootpart for every player!

1
I think so. I actually believe if you look through the website, you'll find an answered question and know how to check. alphawolvess 1784 — 9y
0
I read a forum post, thank you yogipanda123 120 — 9y

1 answer

Log in to vote
2
Answered by
Sublimus 992 Moderation Voter
9 years ago

You can check the weld's part1 and use :GetPlayerFromCharacter() to find the player sitting in the seat. I'll explain as I go through:

script.Parent.ChildAdded:connect(function(child) -- When an object is added to the seat
    if child.Name == "SeatWeld" then -- Make sure the object is a seat weld
        local root = child.Part1 -- Get the part that it is welded too
        local char = root.Parent -- Get the parent of the part
        if char:findFirstChild("Humanoid") then -- If the parent of the part contains a humanoid, we know it is a players character
            local player = game.Players:GetPlayerFromCharacter(char) -- Get the player from the character
            print(player.Name) -- Print the player's name
        end
    end
end)
Ad

Answer this question