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

I am trying to make a kill function but it is not working can someone help me?

function die(hit)
	if hit.Parent:FindFirstChild("Huminoid") then
		hit.Parent.Head:Destroy()
	end
end
die()

I am trying to make a function that kills the player when they touch the parent of this script but it keeps on saying: Workspace.Part.Script:2: attempt to index local 'hit' (a nil value)

1 comment

0

Could it possibly be the fact you misspelt Humanoid?

1 answer

###Use http://wiki.roblox.com/index.php?title=API:Class/BasePart/Touched

So:

script.Parent.Touched:Connect(function(hit)
    if hit.Parent:FindFirstChild("Huminoid") then
        hit.Parent.Head:Destroy()
    end
end)

So the issue you were having is that you were calling the function not only once, but with no arguments, you need to call it when something touches a part.

2 comments

1

Another issue is, he's trying to find Huminoid

0

And he should use FindFirstChildOfClass. Names can change.

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