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?
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
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()
Line 3 will not work: first off, it's missing an end, 2nd, for a function, you NEED to call on it for it to fire, 3rd, "R" isn't used anywhere else in the code (it's defined, but not used), and 4th, you don't require the extra parentheses around character & Destroy().
pls no
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()
This discussion is preserved as it was. New answers, comments, and votes are closed.
3 comments
Use userinputservice
You can kill the player to do it but it would be better to use a remote event and use the LoadCharacter() function.
http://wiki.roblox.com/index.php?title=API:Class/UserInputService