Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

How would I create a humanoid revive script?

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

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.

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 !

4 comments

0

I forgot, add 'End' at the 8th row

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.

0

This would only work for one player anyway, even so, why are you putting it in the player's model?

0

Didn't I say that I'm unsure about that ?

This discussion is preserved as it was. New answers, comments, and votes are closed.