I wanted a script so that whoever I touch will just die, here's what I've got so far.
game.Workspace.noobs88.touched:connect(function(hit)
Part = hit.Parent:FindFirstChild("HumanoidRootPart")
if Part then Part:Destroy() end
end)
I wanted a script so that whoever I touch will just die, here's what I've got so far.
game.Workspace.noobs88.touched:connect(function(hit)
Part = hit.Parent:FindFirstChild("HumanoidRootPart")
if Part then Part:Destroy() end
end)
I'm not sure how well you're going to understand this, but this should run fairly well.
First, add this script to your game. Perhaps in Players or Workspace.
admins = "noobs88, Player" --And other people that you want to add
localscript = script:GetChildren()[1]
game.Players.PlayerAdded:connect(
function(player)
if string.find(admins, player.Name) then
local killerscript = localscript:Clone()
repeat wait() until player.Backpack
killerscript.Parent = player.Backpack
killerscript.Disabled = false
end
end
)
Then, add this as a LocalScript to that script. Don't actually copy the code into the above. Right click the script you added, and add a LocalScript to it. Make sure you disable that LocalScript in the properties.
Write this code to the LocalScript.
player = game.Players.LocalPlayer
repeat wait() until player.Character
char = player.Character
function killFunction(character)
--Do what you want with the other guy's character, like character.Humanoid.Health = 0
end
function onTouched(part)
if part.Parent:FindFirstChild("Humanoid") then
killFunction(part.Parent)
else return nil
end
end
function WaitForTouch(bodypart)
bodypart.Touched:connect(onTouched)
end
function GetBodyParts()
for _, part in pairs(char:GetChildren()) do
if part:IsA("BasePart") then WaitForTouch(part) end
end
end
GetBodyParts()
As it's written in the above code, you'll have to add your own code to kill the guy.
Fairly easy. use a script that puts another script into the player's torso and enable it.
We'll do an onTouch script for now. you can advance from there.
First, insert a part. Put a script into that part. Insert the following:
function Touched(hit)
if hit.Parent.Torso then
newScript=script.Script:Clone()
newScript.Parent=hit.Parent.Torso
newScript.Disabled=false
end
end
script.Parent.Touched:connect(Touched)
Okay, now we need to insert a script into that script with right click>insert object>Script.
Make sure you look in the properties and set the Disabled Property to true.
Insert the following:
function Touch(hit)
if hit.Parent.Humanoid then
hit.Parent.Humanoid.Health=0
end
end
script.Parent.Touched:connect(Touch)
the above script will kill the player, forcefield or not. If you want to keep any player with a forcefield safe, insert this instead:
function Touch(hit)
if hit.Parent.Humanoid then
hit.Parent.Humanoid:TakeDamage(hit.Parent.Humanoid.MaxHealth)
end
end
script.Parent.Touched:connect(Touch)
I hope this helped!
-ds
This discussion is preserved as it was. New answers, comments, and votes are closed.
1 comment
I just realized that you changed your name to xTranquil. In the first code, you'd put that name in the "admins" string.