#this is not working for no reason
112 messages · Page 1 of 1 (latest)
script.Parent.Touched:Connect(function(otherPart)
local character = otherPart.Parent
local humanoid: Humanoid = character:FindFirstChildOfClass("Humanoid")
if humanoid and humanoid.Health > 0 then
humanoid.Health = 0
end
end)
parent a script to your part and paste this code
At least explain the code so he can understand properly how it works.
real
I'll help you understand this in a bit
Also I NEED consent
Because this kill brick will
Doxx the player
Permamently ban the player
Deletes everything in the workspace
oh wait it worked
Oh nvm
but i didnt under anything of this code
Understand?
script.Parent.Touched:Connect(function(otherPart)
local character = otherPart.Parent
local humanoid: Humanoid = character:FindFirstChildOfClass("Humanoid")
if humanoid and humanoid.Health > 0 then
humanoid.Health = 0
end
end)
yeah
Touched = when player touch the part duh
ik
wait
Local character finds the character
Who touched the part
Uwu
And then it will select humanoid
Set health to 0
Done simple
what is the diffrence between findfirstchild and findfirstchildofclass
findfirstchild finds the thing with the provided name
and ofclass?
findfirstchildofclass finds the class of an instance
for example findfirstchildofclass("Humanoid")
or BasePart
or MeshPart
alr thanks
The difference between FindFirstChild and FindFirstChildOfClass in Roblox Lua is in what they search for and how specific their search criteria are.
theres alot of classes 
lmao
** You are now Level 2! **
dude
um guys just help me im new
im assuming because of that you do not know nothing
so uuuhhh
In Lua, including Roblox Lua scripting, the difference between local function and function pertains to the scope and visibility of the function.
read this
it will teach you lots of useful stuff
He aint reading allat
Local function is find player and execute it to only them
Function = everyone else
well idk how else he suppost to know 
what youtube tutorials? that would work
my problem is when i search for tutorial in utube its old and their codes doesnt work
thats why you read da docs
dis ting
👍
its by roblox themselves
and updated
Use “Youtube”
Not utube
"Youchube" ☕
local Part : BasePart = script.Parent
--[[
-- The part that's outside the script.
-- the ": BasePart" is a method for letting the code know to what class to expect to.
-- It let's the script know that we are dealing with a humanoid type when we addressed the local.
-- This allows to the code error properly, and you to autocomplete it's functions and signals.
-- The same is done with the humanoid.
-- ]]
function onTouch(BasePart)
-- The function onTouch (look at the last line to understand the setup)
-- This function comes with the argument "BasePart" from the ".Touched" signal which is the BasePart that touched our Part.
local Character = BasePart.Parent
local Humanoid : Humanoid = Character:FindFirstChildOfClass("Humanoid")
--[[
-- Since we want to detect if a player is touching the part,
-- we are trying to figure out if we the touching BasePart is actually one of them.
-- If a leg for example is that touching BasePart we assume we can go to it's parent, the character,
-- and find the humanoid inside it to kill the player.
-- As for the :FindFirstChildOfClass() it's a function to find the instance with the class name we insert, in our case it's the humanoid.
--]]
if Humanoid and Humanoid.Health > 0 then
Humanoid.Health = 0
end
--[[
-- Here we are checking if we have a humanoid (and) a living humanoid.
-- We do this check so we can verify that the character was actually a character
-- and the same for the humanoid.
-- If both conditions are met, we set the health to 0 so the player will die.
-- ]]
end -- The end of the function.
Part.Touched:connect(onTouch)
--[[
-- Here we set a connection to the function "onTouch"
-- This function executes once the signal ".Touched"
-- has been activated, which is whenever a BasePart type
-- is touching the BasePart we are connecting it to.
-- ]]
This is for you too @edgy berry
Yes?
may i ask u a quetion
Shoot it
local humanoid : humanoid what does it do
like
what does it mean
like just type local humanoid equal
It let's the script know that we are dealing with a humanoid type when we addressed the local.
This allows to the code error properly, and you to autocomplete it's functions and signals.
I apologize I'm writing from mobile.
If you meant me
like i mean here
alr ty
So yeah beware that Lua like most programming languages are case sensitive to anything.
Gust
@edgy berry if you need me I'm here
how do i add sound when a player touches this part
Make the question more specific, do you want the sound to play for the one who dies alone?
yeah
You might be aware that the humanoid already plays a death sound, it can just be overwritten.
You can see how to do that with a quick online search.
https://devforum.roblox.com/t/how-do-you-change-the-death-sound/2778411/20
I should have read all the messages. I just saw a picture where you are using a LocalScript. Well, I guess that’s my mistake then. But I guess I will still let my post be in here You are probably using a ServerScript. You should use a LocalScript instead because the sounds inside the HumanoidRootPart only exist on the client. That means a Serve...
Yes, that's exactly what I explained.
sue?