I dont get what the parameter does in this code

Hello! Newbie Developer here! I’m wondering what the parameter does in this code? I’ve read the developer website and still i didn’t understand anything about it

Code:

local lava = script.Parent

local function killPlayer(otherPart)
local partParent = otherPart.Parent
local humanoid = partParent:FindFirstChild(“Humanoid”)
if humanoid then
humanoid.Health = 0
end
end

lava.Touched:Connect(killPlayer)

1 Like

Hello there!

The parameter in your code (otherPart) is for specifying/checking what type of object has touched the lava brick. Is that a person or a block?

So you did well and looked for a humanoid.

local lava = script.Parent

local function killPlayer(otherPart)
local partParent = otherPart.Parent --Getting the parent of the model
local humanoid = partParent:FindFirstChild(“Humanoid”) --Checks if there is a humanoid
if humanoid then --If it has a humanoid then
humanoid.Health = 0 --Changes humanoid health to 0
end
end

lava.Touched:Connect(killPlayer) --Touch function

The parameter represents the part which touched the part named “lava” resulting in its “Touched” event firing.