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

My kill script isn't working... Solution?

--Having trouble with a kill script:

script.Parent.ClickDetector.MouseClick:connect(function(player) game.Workspace.player.Torso:remove() end)

--(I want to kill the player by removing the torso and setting the players health to 0)

2 answers

So, you're understanding parameters, which is awesome.

"player" isn't the Player's name, but it's the actual Player

So instead of...

script.Parent.ClickDetector.MouseClick:connect(function(player) game.Workspace.player.Torso:remove() 
end)

You would first get the Player's name (player.name), then use :FindFirstChild() to find any object with that specific name.

script.Parent.ClickDetector.MouseClick:connect(function(player) game.Workspace:FindFirstChild(player.Name).Torso:Destroy()
end)

That should work, tell me if it doesn't!

1 comment

0

Ew

It gives the the player, you don't have to find it in workspace.

script.Parent.ClickDetector.MouseClick:connect(function(player)
	player.Torso:Destroy()
end)
Use Destroy, not remove.

Good Luck!

If I helped you, please don't forget to accept my answer.

4 comments

0

Another, more satisfying way to kill a player, is using player:BreakJoints(). It's also more resistant to bugs.

0

using anonymus functions to teach a new player is not a good idea, all it does is make your script more fancy and confusing to read, teach advanced people with it

0

I'm not using them to teach, he already knows them. This is the most stupid thing I've ever read.

0

yea, use destroy(). remove is depreciated/shouldn't be used anymore

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