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.
4 comments
I forgot, add 'End' at the 8th row
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.
This would only work for one player anyway, even so, why are you putting it in the player's model?
Didn't I say that I'm unsure about that ?