I have a basic script here that when "W" is pressed something will happen, but what I need to happen I don't know the code for.. Does anyone know what the code is that will kill the player if touched?
function onKeyPress(inputObject, gameProcessedEvent) if inputObject.KeyCode == Enum.KeyCode.W then --What goes here?-- end end game:GetService("UserInputService").InputBegan:connect(onKeyPress)
If this is a LocalScript which I think it is I think this will work.
local player = game.Players.LocalPlayer function onKeyPress(inputObject, gameProcessedEvent) if inputObject.KeyCode == Enum.KeyCode.W then player.Character:BreakJoints() -- or player.Character.Humanoid:TakeDamage(999) end end game:GetService("UserInputService").InputBegan:connect(onKeyPress)
local plr = --Player
function onKeyPress(inputObject, gameProcessedEvent) if inputObject.KeyCode == Enum.KeyCode.W then workspace[plr.Name].Humanoid.Health = 0 end end
Closed as Not Constructive by User#19524
This question has been closed because it is not constructive to others or the asker. Most commonly, questions that are requests with no attempt from the asker to solve their problem will fall into this category.
Why was this question closed?