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

Help Me Please. KillBrick Script Not Working? DDDDDDDLWOW

Asked by
Cvbza 12
6 years ago
Edited 6 years ago

So I Have A KillBrick Script When It Is Touched The Player Dies. What Is My Error If There Is? Sorry For The Title. The Title Filter Is Kinda Bad.

Script.Parent.Touched:Connect(Function(Hit)
    If (Hit ~= Nil) Then
        If (Hit.Parent) Then
            If (Hit.Parent:FindFirstChild("Humanoid")) ~= Nil Then
                    Hit.Parent:FindFirstChild("Humanoid").Health = (0)
            End
        End
    End
End)

was

0
the number "0" shouldn't be in parenthesis. DeceptiveCaster 3761 — 6y
0
Quite surprised you have managed to put a close bracket at the last end if the end wasn't done correctly... brokenVectors 525 — 6y
0
I have OCD too but unfortunately lua requires some lowercase. andrewcooke582 -52 — 6y
0
Hit ~= Nil is not needed because it will only fire when something hits it lmao so hit would never be nil! EliteMackan 0 — 6y

3 answers

Log in to vote
3
Answered by 6 years ago
Edited 6 years ago

There are several problems with capitalisation in your code. Case-sensitivity must always be taken into account or your code will have problems.

script.Parent.Touched:Connect(function(hit)
    if hit then
        if hit.Parent:FindFirstChild("Humanoid") then
            hit.Parent.Humanoid.Health = 0
        end
    end
end)

I've tidied up your code a bit, but if you wanted to go slightly further you could do:

script.Parent.Touched:Connect(function(hit)
    local hum = hit.Parent:FindFirstChild("Humanoid")
    if hum then
        hum.Health = 0
    end
end)
Ad
Log in to vote
0
Answered by 6 years ago
script.Parent.Touched:connect(function(hit)
    if hit.Parent:FindFirstChild("Humanoid") then
        hit.Parent.Humanoid.Health = 0
    end
end)
0
Haha I've got the shortest one! That means I am the master scripter! EliteMackan 0 — 6y
1
Looking at your rep you're not the master scripter here lmao, oh and, I can do the same thing on one line, everyone can User#20388 0 — 6y
1
Agreed with Redcommander. Also, connect() is deprecated, use Connect() Amiaa16 3227 — 6y
0
You are just jealous of my scripting skills, get on my level. EliteMackan 0 — 6y
Log in to vote
0
Answered by
hellmatic 1523 Moderation Voter
6 years ago
script.Parent.Touched:Connect(function(hit)
    if game.Players:FindFirstChild(hit.Parent.Name) then 
        game.Players:FindFirstChild(hit.Parent.Name).Character:BreakJoints()
    end
end)
0
(: hellmatic 1523 — 6y

Answer this question