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

How to make character Reset after they click a GUI Button?

Asked by 7 years ago

Okay So Im Making a Game and I have a team change GUI! But after its clicked I want the Player To Be Reset So they can Start! How do I do this?

2 answers

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

Methods

There are several different ways to reset a player's character, all in which practicality varies in circumstance. Here's a few different methods, and how they differ:

  • TakeDamage

    • TakeDamage is a method that belongs to a character's Humanoid, which will deal the number of damage that was given through the function. However, it will not damage the Humanoid if a ForceField instance is present. Example: Humanoid:TakeDamage(50)
  • BreakJoints

    • BreakJoints is another method capable of killing the player, except this one is a member of the player's Character, not Humanoid. This will disconnect all joints connected to the character's Torso, killing the player. However, it's only the neck joint, or the Torso itself that has to be absent from the player in order to kill it. Example: Character:BreakJoints()
  • Health

    • Another way of inflicting damage to a player, is simply setting it's Humanoid's Health property to a new value. This, unlike TakeDamage, will not cease to damage the player regardless of a ForceField. Example: Humanoid.Health = 0 or Humanoid.Health = Humanoid.Health - 50 (Same as Humanoid:TakeDamage(50), except will damage regardless of a ForceField.)

Implementation

Implementing any of these methods is pretty simple, just choose whichever type of mouse input you'd like to interact with the TextButton such as MouseButton1Up, MouseButton1Click, etc... Then connect that event with your chosen method of killing the player, and bravo.

TextButton.MouseButton1Click:Connect(function()
    --Humanoid:TakeDamage(###)

    -- Either of these is probably what you want for your circumstance.

    --Character:BreakJoints()
    --Humanoid.Health = 0
end)

Hope this helped. If you have any questions, let me know.

0
Perfect personal_ly 151 — 7y
Ad
Log in to vote
0
Answered by
RubenKan 3615 Moderation Voter Administrator Community Moderator
7 years ago

we can use a MouseButton1Click event on the Button, then break the joints of the character, wich will result in the character dying.

button.MouseButton1Click:Connect(function()
game.Players.LocalPlayer.Character:BreakJoints()
end)

Answer this question