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
7 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.
if game.Players.LocalPlayer.Character.Humanoid.Health == 100 then 
    function action()
    game.Players.LocalPlayer.Character.Humanoid.MaxHealth = 9999
    game.Players.LocalPlayer.Character.Humanoid.Health = 9999
    game.Players.LocalPlayer.Backpack.Clean:Remove()
    wait(0.1)
    local time = 60
    for i = 1, 60 do
    wait(1)
    time = time - 1
    script.Parent.Text = tostring(time) 
end
    game.Players.LocalPlayer.Character.Humanoid.Health = 100
    game.Players.LocalPlayer.Character.Humanoid.MaxHealth = 9999
    game.Lighting.Tools.Clean:Clone().Parent = game.Players.LocalPlayer.Backpack


end
end






script.Parent.MouseButton1Click:connect(action)
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 — 7y

1 answer

Log in to vote
1
Answered by 7 years ago
player = game.Players.LocalPlayer 
repeat wait() until player.Character --Threw this here just as a just in case.
character = player.Character
    script.Parent.MouseButton1Click:connect(function() -- function begins here
        if character.Humanoid.Health == 100 then -- if starts here
            character.Humanoid.MaxHealth == 9999
            character.Humanoid.Health == 9999
            game.Players.LocalPlayer.Backpack.Clean:Remove()
            wait(0.1)
            local time = 60
                for i = 1, 60 do --loop starts here
                wait(1)
                time - time - 1
                script.Parent.Text = tostring(time)
            end -- loop ends here
        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.
        character.Humanoid.Health = 100
 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. 
    end-- if ends here
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.

Ad

Answer this question