Like you character dies and you have to press space or r to respawn.also can it work for a button to?
✓ ANSWER ACCEPTED
Is there a way to make your character spawn by pressing a key?
2 answers
✓ Accepted answer
you can use a variation of the below code, detects a keyboard input and reacts to the input: (UserInputService)
local UserInputService = game:GetService('UserInputService')
function onInputBegan(input,gameProcessed)
if input.KeyCode == Enum.KeyCode.Up then
-- Up arrow
end
end
UserInputService.InputBegan:connect(onInputBegan)
other keys (including r) can be found here
Use a local script Insert a Vector3 Value inside of the script
Player = game.Players.LocalPlayer
Mouse = Player:GetMouse()
repeat wait() until Player.Character
Character = Player.Character
Character.Humanoid.Died:connect(function(died)
Character.Torso.Position = script.Value.Value
Mouse.KeyDown:connect(function(key)
if key == "r" then
player:LoadCharacter()
end
end)
end)
Try this
This discussion is preserved as it was. New answers, comments, and votes are closed.

3 comments
Forget about the vector 3 value not needed
Add a wait before the load character thingy
Down vote for using deprecated APIs.