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

So everything works but if the health is at 1 it still does everything help?

Asked by
roudgy 0
8 years ago

Please provide more explanation in your question. If you explain exactly what you are trying to accomplish, it will be much easier to answer your question correctly.
01if 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)
12end
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
View all 26 lines...
0
We can not help you if you do not explain what is going wrong, what's supposed to happen, what errors there are if any, etc. M39a9am3R 3210 — 8y

1 answer

Log in to vote
1
Answered by 8 years ago
01player = game.Players.LocalPlayer
02repeat wait() until player.Character --Threw this here just as a just in case.
03character = player.Character
04    script.Parent.MouseButton1Click: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
20end --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.

Ad

Answer this question