Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

Why is my bleeding script not working?

Asked by
IcyEvil 260 Moderation Voter
8 years ago

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)
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? PreciseLogic 271 — 8y
0
The damage portion of the script works however the actual blood drop portion does not. IcyEvil 260 — 8y
0
Why do you repeat "blood = Instance.new("Part")" twice? thehybrid576 294 — 8y
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. LostPast 253 — 8y

1 answer

Log in to vote
1
Answered by
TrollD3 105
8 years ago

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)



0
Works Thank You! IcyEvil 260 — 8y
Ad

Answer this question