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

How do I stop this error from occuring?

This error just randomly started happening, it is "Bleeding is not a valid member of tool"

Here is the block of code causing the error:

if Part and Part.Parent:FindFirstChild("Humanoid") ~= nil then
	local bleed = script.Parent.Bleeding:Clone()
	bleed.Parent = Part.Parent:FindFirstChild("Humanoid")
	bleed.Value = true
	
	local damage = 10
	if Part.Name == "Head" then
		damage = math.random(50,70)
		bleed.BleedDamage.Value = 42.5
	end
		if Part.Name == "Torso" or Part.Name == "HumanoidRootPart" then
			damage = math.random(20,25)
			bleed.BleedDamage.Value = 50
		end

Basically there is a "Bleeding" object in the tool that needs to be cloned and put into the humanoid the pistol is doing damage to, Part is the Part/BasePart it hit.

2 comments

0

Just check wether bleeding is not equal to nil and Use FindFirstChild as it finds the first child of a tool that beginnes with Bleeding

0

And make sure you clone whatever you want to the local players backpack

2 answers

You could use :WaitForChild() to wait until the member appeared

if Part and Part.Parent:FindFirstChild("Humanoid") ~= nil then
    local bleed = script.Parent:WaitForChild("Bleeding"):Clone()
    bleed.Parent = Part.Parent:FindFirstChild("Humanoid")
    bleed.Value = true

    local damage = 10
    if Part.Name == "Head" then
        damage = math.random(50,70)
        bleed.BleedDamage.Value = 42.5
    end
        if Part.Name == "Torso" or Part.Name == "HumanoidRootPart" then
            damage = math.random(20,25)
            bleed.BleedDamage.Value = 50
        end

1 comment

0

uhhh.. Why someone downvoted my question ?

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