I changed a few words and variables in a script and it won't work anymore

HI! I’m very new in scripting and I have been trying to learn through the devhub. In the course, they said how to make a kill block and this is the finished code they provided:

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)

The script works but when I change some parts of it and I made it to this:

local lava = script.Parent

local function kill(tao)
local party = tao.Parent
local human = party:FindFirstChild(“Humanoid”)
if human then
human.Health = 0
end
end

lava.Touched:Connect(kill())

The script won’t work anymore. I don’t know what is wrong, Even after I read the tutorial a lot of times. I still also don’t get what is a parameter, and what I did wrong (due to English being my second language).

So my questions are:
what are parameters, and what do they do

why won’t the script work after I changed a few words and variables

Thank you!

I changed the script a bit to understand more about the script, but I still don’t get it.

i believe i think it was bcuz this:

lava.Touched:Connect(kill())

remove the parenthesis:

lava.Touched:Connect(kill)

EDIT: i forgot u were new but if you want to add paranthesis make sure you add arguements there; if you don’t want to then delete it; adding paranthesis probably makes it so the passed arguement are 0’s.

1 Like

Thank you so much! I haven’t thought of doing that. But what do parameters do?

im gonna explain it to you real quick:
so say we call a function name called “testing”
if it’s connected in the connect event basically like this:

Connect(testing())

you see there are no arguement to pass
so let’s create some variable called “pass_example” that is equivalent to 5
now inside “tessting” function is this

testing(pass1)
   print(pass1)
end

now the connect function is simply this:

Connect(testing(pass_example))

if you do not give it some passed arguement it can error atleast for me
deleting the parameter will instead make it so the connected function pass some arguement to the function
I probably explained it bad

1 Like

My understanding got a bit better now thanks to your reply. But I still need to learn more about it. Thank you for explaining!

I have one last question. in the

local function killPlayer(otherPart)
local partParent = otherPart.Parent

What is the parent of the otherPart? is it the function? or the whole script?

otherpart is basically the hit
whenever a part touches things it hits a child.
an example of child:

model --the mother
 --inside the model:
  >Part --the child.

so it’s quite easy to explain:
say a part touches a player
i’d assume the part touched a right leg! the child of a player model!
part.Parent < easy explaination. Parent is basically what part is housing onto.