Confused on what this code means

Hi, I’ve been trying to learn Lua for the past couple of days and I’m really confused on killPlayer(otherpart.) What does “(otherpart)” even mean??

Anyways, here’s the code:

  1. local lava = script.Parent
  2. local function killPlayer(otherPart)
  3. end
  4. lava.Touched:Connect(killPlayer)

I think “otherpart” means the body part you touched the brick with. I’m not sure though.

1 Like

The code itself technically does not do anything other than listen to when the part the script is in gets touched.

otherPart is the object that touched the part the script is in.

3 Likes

this should be in #help-and-feedback:scripting-support not #help-and-feedback:code-review

1 Like

ohhh ok i got it, so its just any part? but what if i had multiple parts that arent humanoids touch it? wouldn’t that lag the game?

The event firing multiple times a second doesn’t have a major performance impact to my knowledge. What’s important is you properly check if the part/s that touch belong to a character.

2 Likes