✓ Accepted answer
Error Message
The error you're getting is basically saying that killPlayer errored, which means that the PlayerAdded event is going to ignore it from then on.
Problems
You don't care about the particular player named "Player", probably -- you should probably be merging blah and player.
Actually, blah (or what you mean to be blah) is a parameter of the PlayerAdded event:
function newPlayer( player )
end
game.Players.PlayerAdded:connect( newPlayer )
Note that Player objects don't have a Humanoid in them. It's in their Character, but their Character won't be there the moment the player appears (it takes a little time to spawn) so we should wait for that to happen:
repeat
wait()
until player.Character
Now we can make a simple killPlayer function that kills the player's Character's Humanoid:
function killPlayer( player )
player.Character:WaitForChild("Humanoid").Health = 0
end
Correct Program
Putting it all together:
function killPlayer( player )
player.Character:WaitForChild("Humanoid").Health = 0
end
function newPlayer( player )
repeat
wait()
until player.Character
killPlayer( player )
end
game.Players.PlayerAdded:connect(newPlayer)
Lesson
Don't just write things down because they look right.
Every little piece of a program has a purpose, down to the quotes. Make sure you know why you picked something -- if you don't know, you shouldn't have picked what you did.
3 comments
On line 11, try putting 'game.Players.PlayerAdded:connect(killPlayer())' -- I added the parenthesis after the 'killPlayer' function.
Keep in mind, I put this in a comment because I am not 100% sure that is the issue. (I cannot test it at the moment)
Nope, that doesn't work. I still get a disconnected event because of exception. qq