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

Why is my bleeding script not working?

My bleeding script does not work correctly, the damage part does work but well yeah...

The blood portion does not work however, so can anyone help me figure out how to fix this?

Any and all help is appreciated.

script.Parent.Touched:connect(function(hit)
	if hit.Parent then
		local hum = hit.Parent:findFirstChild("Humanoid")
		if hum then
		local character = hit.Parent
		
local blood = Instance.new("Part")
blood = Instance.new("Part")
blood.Material = Enum.Material.Granite
blood.BrickColor = BrickColor.new("Really red")
blood.Anchored = false
blood.Locked = true
blood.Size = Vector3.new(1,1,1) 

local BloodClone = blood:Clone()
local torso = character:findFirstChild("Torso")
local brick = script.Parent

function bloodspawn()
	BloodClone.Parent = torso
	BloodClone.Position = CFrame.new(torso.Position.X+1,torso.Position.Y,torso.Position.Z)
		end

function GotHit()
	if hum then
while wait(6) do
	hum.Health = hum.Health - 1
		end
	bloodspawn()
		end
end

GotHit()
		end
	end
end)

4 comments

0

You need to be more specific in "not working", is there no effect at all, is there an error in your code or what?

0

The damage portion of the script works however the actual blood drop portion does not.

0

Why do you repeat "blood = Instance.new("Part")" twice?

0

@EmperorVolvax is not moving the blood to the character and is not placing the blood in the workspace. the blood is spawning in nil and getting auto deleted.

1 answer

✓ Accepted answer

There were a couple of things that caused it not to work. If you are using the Position of a Brick, you have to use Vector3.new(). Not CFrame. You also put the script in a loop so that it would always lose health and never continue. I tried to clean up your code a bit. Hope this helps! Thumbs up if it did!

script.Parent.Touched:connect(function(hit)
    if hit.Parent then
      local hum = hit.Parent:findFirstChild("Humanoid")
        if hum then
          local character = hit.Parent
          blood = Instance.new("Part")
		  blood.Material = Enum.Material.Granite
		  blood.BrickColor = BrickColor.new("Really red")
		  blood.Anchored = false
		  blood.Locked = true
		  blood.Size = Vector3.new(1,1,1) 
          local BloodClone = blood:Clone()
          local torso = character:findFirstChild("Torso")

		function bloodspawn()
    		BloodClone.Parent = torso
    		BloodClone.Position = 		Vector3.new(torso.Position.X+1,torso.Position.Y,torso.Position.Z)
       end

		function GotHit()
    		if hum then
				while wait(2) do
   				 hum.Health = hum.Health - 1
				 bloodspawn()
				 break --remove this if you dont want the script to end
			 end
         end
      end

GotHit()
        end
    end
end)



1 comment

0

Works Thank You!

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