Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

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

Asked by 4 years ago
Edited 4 years ago

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)
0
Put ALL of your code in a code block. Dovydas1118 1495 — 4y
0
Ok badimo3456p 114 — 4y
0
Ok badimo3456p 114 — 4y

2 answers

Log in to vote
2
Answered by 4 years ago

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.

Ad
Log in to vote
0
Answered by
goodlead -62
4 years ago

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)

Answer this question