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

How To Find the character who's sat on a seat part?

So long story short I've been trying to find a way to find the character of a person who's been sat on a seat usually it ends up in an error with it returning as a nil. I've already tried using seat.Occupant and the lot really and I'm a little lost.

I need to find the character for the seat to be able to change their max health and health.

Any help?

1 answer

✓ Accepted answer

Ok so you need to find out what is touching the part. So

local seat = script.Parent -- or whatever it is
seat.Touched:Connect(function(hit) -- function to see who touched
	local char = hit.Parent -- hit is the part that touches the leg
	if char then -- checks to see if character is there
		print(char.Name) -- prints the name
end
end)

1 comment

0

make sure u add a debounce

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