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)
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)