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

Kill brick fails to do anything?

function onTouched(hit)
	if hit.Parent.Humanoid ~= nil then
		for i = 1, 20 do
			hit.Parent.Head.Size = hit.Parent.Head.Size + Vector3.new(0.5, 0.5, 0.5)
			wait()
		end
	hit.Parent.Humanoid.Health = 0
	end
end

The brick should make the player's head inflate and then kill the player. However, when I test it, nothing happens. There is no error in the output, but my guess is that I screwed up the function on line 1. Can anyone help?

1 answer

✓ Accepted answer

This function doesn't have an event listener attached to it. As of now, nothing will happen because nothing can trigger it!

Try this:

function onTouched(hit)
    if hit.Parent.Humanoid then
        for i = 1, 20 do
            hit.Parent.Head.Size = hit.Parent.Head.Size + Vector3.new(0.5, 0.5, 0.5)
            wait()
        end
    hit.Parent.Humanoid.Health = 0
    end
end
script.Parent.Touched:connect(onTouched) --Add a connection line

Also, quick suggestion:

Whenever you're checking to see if something is nil, all you need to do is:

if hit.Parent.Humanoid then

Because, by default, it'll check if it's nil unless told to do otherwise.

1 comment

0

Oh, I feel stupid. Thanks!

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