Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

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

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!

2 comments

1

I think so. I actually believe if you look through the website, you'll find an answered question and know how to check.

0

I read a forum post, thank you

1 answer

✓ Accepted answer

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)

This discussion is preserved as it was. New answers, comments, and votes are closed.