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

Hurting specific parts of the player?

So I tried to make a script where it gives damage to a specific part of the body but it does not work correctly. Any help? ~Thanks.

	beam.Touched:connect(function(hit)
		local name = hit.Parent.Parent.Name
		if not name then
			local humanoid = hit.Parent:FindFirstChild("Humanoid")
			if not humanoid then
				humanoid = hit.Parent.Parent:FindFirstChild("Humanoid")
			end
			local limbs = hit.Parent:findFirstChild("Right Arm") 
			or hit.Parent:findFirstChild("Right Shoulder")
			or hit.Parent:findFirstChild("Right Hip")
			or hit.Parent:findFirstChild("Right leg")
			or hit.Parent:findFirstChild("Left Hip")
			or hit.Parent:findFirstChild("Left Leg")
			or hit.Parent:findFirstChild("Left Arm")
			or hit.Parent:findFirstChild("Left Shoulder")		
			local chest = hit.Parent:findFirstChild("Torso")
			local head = hit.Parent:findFirstChild("Head")
			if chest then
				if humanoid then
					humanoid:TakeDamage(props.chestDamage)
				end
			end
			if head then
				if humanoid then
					humanoid:TakeDamage(props.headDamage)
				end
			end
			if limbs then
				if humanoid then
					humanoid:TakeDamage(props.limbDamage)
				end
			end
		end
	end)

1 answer

You've messed up on your capitals. Lua scripting is case-sensitive. It's FindFirstChild:()

2 comments

0

It still does not work

0

Also, findFirstChild is a deprecated version of FindFirstChild. They do the exact same thing.

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