Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
2

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

Asked by
mxpvjn 75
7 years ago
Edited 7 years ago

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

Log in to vote
0
Answered by 7 years ago
Edited 7 years ago

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!

0
Ew User#11440 120 — 7y
Ad
Log in to vote
0
Answered by 7 years ago
Edited 7 years ago

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.
0
Another, more satisfying way to kill a player, is using player:BreakJoints(). It's also more resistant to bugs. User#11440 120 — 7y
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 Crystalsweeper 25 — 7y
0
I'm not using them to teach, he already knows them. This is the most stupid thing I've ever read. User#11440 120 — 7y
0
yea, use destroy(). remove is depreciated/shouldn't be used anymore PreciseLogic 271 — 7y

Answer this question