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

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

Asked by 5 years ago

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

Log in to vote
0
Answered by 5 years ago

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)
0
make sure u add a debounce WillBe_Stoped 71 — 5y
Ad

Answer this question