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)
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.