What should I do to recognize the person in the car or motorcycle when touched?

What should I do to recognize the person in the car or motorcycle when touched?

I keep trying, but I can’t get the hang of it.

Depends, if you just need to detect when someone is sitting on a VehicleSeat you could something like this:

local VehicleSeat = script.Parent

VehicleSeat:GetPropertyChangedSignal("Occupant"):Connect(function()
	if VehicleSeat.Occupant then
		-- if player is sitting
	else
		-- if player is not sitting
	end
end)

but if you need to check if someone is in a certain radius of the vehicle you can use something like ZonePlus (which uses the somewhat new Spatial Query API).

1 Like

Thank you for your answer. ^^ I want to know who is in that car when I Thank you for your answer. ^^ If someone hits the wall I made while driving while riding a bicycle or car, I want to know the person driving from the perspective of the wall.hit a wall while riding a bicycle or car. From the wall’s point of view ^^

-- i solved ^^
-- Initially connect all gold chunks to touch detection
for _, chunk in pairs(CollectionService:GetTagged("Gold")) do
	chunk.Touched:Connect(function(otherPart)
		local wgfbike2 = otherPart.Parent
		local it = wgfbike2.Drive.SeatWeld
		if it:IsA("Weld") and it.Name == "SeatWeld" then
			local player = Players:GetPlayerFromCharacter(it.Part1.Parent)
			if player then
				print("벽 부딪히면 점수 추가")
				processGoldTouch(chunk, GOLD_VALUE, player)
			end
		end

		
	end)
end