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

How do i make players respawn with a key?

Asked by 9 years ago

How can i make people who play the game respawn with a key?

Example: Someone is playing, and then he wanted to respawn. How can i make this player respawn when he presses the R key?

2 answers

Log in to vote
1
Answered by 9 years ago

I explained it the best I could, put this script in StarterGui or StarterPack.

-- Variables
local player = game.Players.LocalPlayer -- Now you can refer to the player
local mouse = player:GetMouse() -- Now you can refer to the mouse

-- Main script
mouse.KeyDown:connect(function(Key) -- When they press a key
    local key = string.lower(Key) -- So if they use caps, there might be a easier way
    if key == "r" then -- If the lower key is r
        player:LoadCharacter() -- Respawn them
    end -- End the if function
end) -- End the function
Ad
Log in to vote
1
Answered by
Necrorave 560 Moderation Voter
9 years ago

Create a local script that calls a function anytime the player presses down the key you assign. Then you can have him respawn a number of ways, whether by killing the current character or by setting a fixed "Spawn location" to go to.

Info on LocalScripts: http://wiki.roblox.com/index.php?title=API:Class/LocalScript

Info on Keyboard input: http://wiki.roblox.com/index.php?title=Keyboard_input

Answer this question