I have Tried this script (i am pretty new) And it didn't kill someone
function onKeyPress (R) (h.Health = 0) end
Anyone know how to make it work?
Wow, nearly a year, well, I'll answer it since it's ez.
Make sure this is in a local script
local mouse = game.Players.LocalPlayer:GetMouse() local player = game.Players.LocalPlayer repeat wait() until player.Character mouse.KeyDown:connect(function(key) if tostring(key) == "r" then player:LoadCharacter() end end)
Set the humanoid health to zero once they pressed R
Get the localplayer(well simple way)
use UserInputService
http://wiki.roblox.com/index.php?title=Keyboard_input
Just destroy the players head when you press R.
local player = game.Players.LocalPlayer local character = player.Character or player.CharacterAdded:wait() function onKeyPress (R) character.Head:Destroy()
Try This Make sure its in ReplicatedFirst. This should work.
-- [[ Main Stuff ]] -- local Player = game.Players.LocalPlayer if Player:FindFirstChild("CanLoad") then else local CanLoad = Instance.new("BoolValue") CanLoad.Parent = Player CanLoad.Name = "CanLoad" CanLoad.Value = true end repeat wait() until Player.Character ~= nil -- [[ Functions ]] -- function Refresh() Player.Character.Humanoid.Died:connect(function() Player:FindFirstChild("CanLoad").Value = false RepeatWaitForRespawn() end) end function RepeatWaitForRespawn() while Player:FindFirstChild("CanLoad").Value ~= true do wait() Player.Character = nil end Player:LoadCharacter(true) Refresh() end local function onKeyPress(inputObject, gameProcessedEvent) if inputObject.KeyCode == Enum.KeyCode.R then Player:FindFirstChild("CanLoad").Value = true end end game:GetService("UserInputService").InputBegan:connect(onKeyPress) Refresh()