Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

How do code lava so when someone touches it, they fall?

How do you make a trap code, because I only know how to make them die, will this help u answer :

script.Parent.Touched:Connect(function(hit)
local character = hit.Parent
local human = character:FindFirstChild("Humanoid")
local player = game.Players:GetPlayerFromCharacter(character)

if player and human.Health > 0  then 
human.Health = 0 
end
end)

3 comments

0

Put ALL of your code in a code block.

0

Ok

0

Ok

2 answers

✓ Accepted answer

Humanoids have a sit property, which you can use to make the "Slip"

script.Parent.Touched:Connect(function(hit)
local character = hit.Parent
local human = character:FindFirstChild("Humanoid")
local player = game.Players:GetPlayerFromCharacter(character)

if player and human.Health > 0  then 
human.Sit = true
end
end

Should wok, if not, then I dunno lol.

Put this code in the block! If this helps please consider giving this an accept and an upvote if helpful!

--[[ I have included a breakdown of what each part does ]]--

local trapPart = script.Parent -- setting the name for the kill brick
trapPart.CanCollide = false -- makes the killbrick hit-able

local function onPartTouch(otherPart) -- function that finds what touched the killbrick
    local partParent = otherPart.Parent --finds the player
    local humanoid = partParent:FindFirstChildWhichIsA("Humanoid") --finds the players health stats
    if humanoid then
        -- Set player's health to 0 aka killing them
        humanoid.Health = 0
    end
end
trapPart.Touched:Connect(onPartTouch)

This discussion is preserved as it was. New answers, comments, and votes are closed.