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

Help Me Please. KillBrick Script Not Working? DDDDDDDLWOW

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

4 comments

0

the number "0" shouldn't be in parenthesis.

0

Quite surprised you have managed to put a close bracket at the last end if the end wasn't done correctly...

0

I have OCD too but unfortunately lua requires some lowercase.

0

Hit ~= Nil is not needed because it will only fire when something hits it lmao so hit would never be nil!

3 answers

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)
script.Parent.Touched:connect(function(hit)
	if hit.Parent:FindFirstChild("Humanoid") then
		hit.Parent.Humanoid.Health = 0
	end
end)

4 comments

0

Haha I've got the shortest one! That means I am the master scripter!

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

1

Agreed with Redcommander. Also, connect() is deprecated, use Connect()

0

You are just jealous of my scripting skills, get on my level.

script.Parent.Touched:Connect(function(hit)
	if game.Players:FindFirstChild(hit.Parent.Name) then 
		game.Players:FindFirstChild(hit.Parent.Name).Character:BreakJoints()
	end
end)

1 comment

0

(:

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