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

Why won't the block kill me when I touch it?

Part = script.Parent

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

2 answers

It worked normal for me. Perhaps its that its parented to something that isnt a part? anyways,

Part = script.Parent
Part.Touched:Connect(function(hit)
	local humanoid = hit.Parent:FindFirstChildWhichIsA("Humanoid")
	if humanoid then
		humanoid.Health = 0
	end
end)

Try this. About your script, it likely wont work because of some scripts that come in free models that change the humanoid's name, and those stuff. Try not using free models. i guess

3 comments

0

I wasn't using free models but the things that I did differently were: 1. I did not put "whichIsA in my findfirstchild command. 2. I used mine in a local script. Do you think I did something wrong

0

You can't use a local script for this if im not wrong.

0

Localscripts only run if they are a descendant of a player and/or a character or the replicated first service

Not sure if this could cause it for setting health to 0 not registering or something, however you could try this.

Part = script.Parent
Part.Touched:Connect(function(hit)
	local char = hit.Parent
	char:BreakJoints()
end)

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