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

How do i code a killbrick system?

Asked by
goodlead -62
4 years ago

I am trying to make and code killbrick for my upcoming obstacle course. The only part of the code I know is :

1local trapPart = script.Parent

Please stay tuned for my new obby.

0
How do I get more reputation? goodlead -62 — 4y
0
Learn the basics please. AntiWorldliness 868 — 4y

3 answers

Log in to vote
0
Answered by 4 years ago

Hi,

Making a Killbrick is overly difficult. There are two versions I use the first being simpler, The second being more complex but gives a better chance of working.

Here is the first one (Simple)

01--[[ I have included a breakdown of what each part does ]]--
02 
03local trapPart = script.Parent -- setting the name for the kill brick
04trapPart.CanCollide = false -- makes the killbrick hit-able
05 
06local function onPartTouch(otherPart) -- function that finds what touched the killbrick
07    local partParent = otherPart.Parent --finds the player
08    local humanoid = partParent:FindFirstChildWhichIsA("Humanoid") --finds the players health stats
09    if humanoid then
10        -- Set player's health to 0 aka killing them
11        humanoid.Health = 0
12    end
13end
14trapPart.Touched:Connect(onPartTouch)

Here is the second script (Advanced)

01function stick(x, y)
02 
03    weld = Instance.new("Weld")
04 
05 
06 
07    weld.Part0 = x
08 
09    weld.Part1 = y
10 
11 
12 
13    local HitPos = x.Position
14 
15 
View all 63 lines...

hope this helps ????

If this is what you are looking for, please click accept answer so the site knows that it has been answered

0
Thanks a lot!!! goodlead -62 — 4y
Ad
Log in to vote
0
Answered by 4 years ago
Edited 4 years ago

Please provide explanation with your answers. Simply posting code does not spread knowledge of integral scripting processes which helps people understand the logic and reasoning behind your answer.

You don't need the local trappart. You can just do this.

1local function onTouched(hit) --The function
2    local h = hit.Parent:FindFirstChild("Humanoid") --This is the humanoid
3        if h then --This checks for a humanoid
4            h.Health = 0 --This removes the humanoid's healthh
5        end
6    end)
7 
8script.Parent.Touched:Connect(onTouched) --This activates the function
0
Thanks A Lot ScriptsALot!!! lol goodlead -62 — 4y
0
Accept and upvote if works please ScriptsALot 91 — 4y
0
How do I upvote? I am new. goodlead -62 — 4y
0
I think you need a certain amount of reputation to upvote. ScriptsALot 91 — 4y
0
Oh ok. goodlead -62 — 4y
Log in to vote
0
Answered by
goodlead -62
4 years ago

Thank you all for your help!!

0
np ScriptsALot 91 — 4y

Answer this question