#kill script

1 messages · Page 1 of 1 (latest)

hardy canopy
#

How do i make it so that if i put a script in here it would make it so that every single thing inside it would kill you if you touch it?

fickle glen
# hardy canopy How do i make it so that if i put a script in here it would make it so that ever...

Using :GetChildren() on the model (if the script was inside it, you'd probably do script.Parent:GetChildren()) and loop through every child, connect to their .Touched events, make sure the part that touched the kill part is actually from a player's character via the Player's service Players:GetPlayerFromCharacter(touchedPart.Parent) and if it is, get their character's humanoid, and set their health to 0

hardy canopy
#

this?

#

-- Place this script inside the model that holds all the parts you want to use

local Players = game:GetService("Players")

-- Loop through all children of the model
for _, part in pairs(script.Parent:GetChildren()) do
if part:IsA("BasePart") then -- Make sure it's a part
-- Connect to the Touched event for each part
part.Touched:Connect(function(hit)
-- Check if the part that touched the model is part of a player's character
local player = Players:GetPlayerFromCharacter(hit.Parent)
if player then
-- Get the Humanoid of the player's character
local humanoid = hit.Parent:FindFirstChild("Humanoid")
if humanoid then
-- Set the player's health to 0 (kill the player)
humanoid.Health = 0
end
end
end)
end
end

fickle glen
#

but it also looks like someone else made this or you AI generated it

hardy canopy
#

my friend sent me it

nova cypressBOT
#

studio** You are now Level 4! **studio

hardy canopy
#

i told him what u told me

#

and he js sent me that

#

also it didnt work

fickle glen
hardy canopy
#

because he told me to tell him how and he does it

#

idk why

#

but he better not be using AI or he gonna mess my game up

#

AI messes your game up never use it

fickle glen
fickle glen
hardy canopy
#

i wanna make it so that if you touch any of him you die

fickle glen
#

Oh no wait sorry. GetDescendants instead of GetChildren

hardy canopy
#

local Players = game:GetService("Players")

for _, part in pairs(script.Parent:GetDescendants()) do
if part:IsA("BasePart") then
part.Touched:Connect(function(hit)
local player = Players:GetPlayerFromCharacter(hit.Parent)
if player then
local humanoid = hit.Parent:FindFirstChild("Humanoid")
if humanoid then
humanoid.Health = 0
end
end
end)
end
end

#

my friend sent me this now

#

is he corr3ect?

#

oh its correct

#

yay

#

but theres a problem

fickle glen
hardy canopy
#

it kills me multiple tiems and makes the guh noise multiple times and glicthes my camera

#

when i die

#

not forever tho when i respawn it stops

fickle glen
hardy canopy
#

wait idek if i have a health bar

fickle glen
hardy canopy
#

wauit how do i check what its at

#

wheres the script to check located?

fickle glen
hardy canopy
#

alright lemme check

#

it worked thanks a lot

fickle glen