how to make kill block in roblox lua

To create a kill block in Roblox Lua, you can use the following code:

local function onTouched(hit)
    local character = hit.Parent
    local humanoid = character:FindFirstChild("Humanoid")
    if humanoid then
        humanoid.Health = 0
    end
end

script.Parent.Touched:Connect(onTouched)

Explanation: 1. We define a function called onTouched that takes one parameter, hit, which represents the object that comes into contact with the kill block. 2. Inside the function, we retrieve the parent of the object that touched the block, assuming it's a character in the game. 3. We then attempt to find the humanoid within the character object. 4. If a humanoid is found, we set its Health property to 0, effectively killing the character. 5. Finally, we connect the onTouched function to the Touched event of the block's parent object to trigger the killing functionality when a character touches the block.