01 | if game.Players.LocalPlayer.Character.Humanoid.Health = = 100 then |
02 | function action() |
03 | game.Players.LocalPlayer.Character.Humanoid.MaxHealth = 9999 |
04 | game.Players.LocalPlayer.Character.Humanoid.Health = 9999 |
05 | game.Players.LocalPlayer.Backpack.Clean:Remove() |
06 | wait( 0.1 ) |
07 | local time = 60 |
08 | for i = 1 , 60 do |
09 | wait( 1 ) |
10 | time = time - 1 |
11 | script.Parent.Text = tostring (time) |
12 | end |
13 | game.Players.LocalPlayer.Character.Humanoid.Health = 100 |
14 | game.Players.LocalPlayer.Character.Humanoid.MaxHealth = 9999 |
15 | game.Lighting.Tools.Clean:Clone().Parent = game.Players.LocalPlayer.Backpack |
01 | player = game.Players.LocalPlayer |
02 | repeat wait() until player.Character --Threw this here just as a just in case. |
03 | character = player.Character |
04 | script.Parent.MouseButton 1 Click:connect( function () -- function begins here |
05 | if character.Humanoid.Health = = 100 then -- if starts here |
06 | character.Humanoid.MaxHealth = = 9999 |
07 | character.Humanoid.Health = = 9999 |
08 | game.Players.LocalPlayer.Backpack.Clean:Remove() |
09 | wait( 0.1 ) |
10 | local time = 60 |
11 | for i = 1 , 60 do --loop starts here |
12 | wait( 1 ) |
13 | time - time - 1 |
14 | script.Parent.Text = tostring (time) |
15 | end -- loop ends here |
16 | character.Humanoid.MaxHealth = 100 -- Noticed that in your other script, you put 9999 instead of 100 right here. Figured that was an issue so I fixed it. |
17 | character.Humanoid.Health = 100 |
18 | game.Lighting.Tools.Clean:Clone().Parent = player.Backpack --I recommend that you put your tools and other stuff into ReplicatedStorage. I personally think it's better, and using Lighting is a bit deprecated. |
19 | end -- if ends here |
20 | end --function ends here |
I shortened up the script and added some stuff that I thought would fix the problem. I also corrected something that bothers me like crazy.
I noticed that you had function action()
then later used script.Parent.MouseButton1Click:connect(action)
.
In my opinionscript.Parent.MouseButton1Click:connect(function()
is easier to use and looks a bit cleaner. You don't have to go through the hassle of naming stuff and making sure that you don't accidentally have two functions named the same thing.
I noted a few other things I fixed. I also set up a few locals so that you didn't have to type out as much, you could simply use the local rather than having to type out an entire location again.
Hopefully, I fixed your issue. Make sure that you start actually telling us what the script does and what the issue is. Granted, you did say that the health goes to 1, but that's not enough for us to go on. We need any errors that pop up, and anything else that happens.