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

How would I create a humanoid revive script?

Asked by 6 years ago

I've been trying things like disabling humanoid death if health is more than 0 when dead but it won't work and switching the humanoid when its dead but nothing is working...

My question is that how would i make a revive script if whenever i change the health of a dead humanoid it just goes back to 0?

2 answers

Log in to vote
0
Answered by
awfulszn 394 Moderation Voter
6 years ago
Edited 6 years ago

You'd most likely use Keyboard Input if you wanted the player to press a button if they had died to revive them.

Keyboard Input:

function onKeyPress(actionName, userInputState, inputObject)
    if userInputState == Enum.UserInputState.Begin then
        print("The revive button was pressed!")
    end
end

game.ContextActionService:BindAction("keyPress", onKeyPress, false, Enum.KeyCode.R)

Or you could use UserInputService or ContextActionService.

UIS:

function onKeyPress(inputObject, gameProcessedEvent)
    if inputObject.KeyCode == Enum.KeyCode.R then
        print("The revive button was pressed!")
    end
end

game:GetService("UserInputService").InputBegan:Connect(onKeyPress)

Note that ContextActionService and UserInputService are only client-side services. So you would have to use a Localscript instead of a ServerScript when using it.

Hope this helped!

This question may be locked as it is a request. And I used the wiki for this information, as I do not create scripts for people or fix them if they are requests, as it wastes my time.

Ad
Log in to vote
-3
Answered by 6 years ago

First of all, what you're doing is a request which is not allowed here. And second,I'll show you just once:

(Name here) = script.Parent.Humanoid

if (Name here).Health = <99 then
wait(1)
(Name here).Health = +5
if (Name here).Health = 100 then
(Name here).Health = +0

Don't thank me yet,I haven't seen anyone ask it before so it is my first time writing such code which means it might not work !

0
I forgot, add 'End' at the 8th row LordTechet 53 — 6y
0
That code is unefficient,why do 2 if statements when you can do elseif? Also that still won't revive the player all that does is regenerate health.If the player is already dead it won't do anything and if he dies before 1 second pasts of 5+ health per second isn't enough to keep him alive,he will still die. farrizbb 465 — 6y
0
This would only work for one player anyway, even so, why are you putting it in the player's model? awfulszn 394 — 6y
0
Didn't I say that I'm unsure about that ? LordTechet 53 — 6y

Answer this question