Blood spill in games

I want some blood in my game. I wrote the following line of code to create a drop of it. But I have no clue how to make more droplets and have them all turn to pools of blood on impact. This is my code:

game.Players.PlayerAdded:Connect(function(player)
	player.CharacterAdded:Connect(function(Character)
		Character.Humanoid.Died:Connect(function(KarlsonIsKill)
			Character.Head:Destroy()

			local blood = Instance.new('Part')
			blood.Color = Color3.new(128, 0, 0)
			blood.Material = Enum.Material.Slate
			blood.Size = Vector3.new(0.1,0.5,0.1)
			blood.Parent = Character.Torso
			blood.CFrame = Character.Torso.CFrame + Vector3(0,3,0)
			blood.Velocity = Character.Torso.CFrame.UpVector * 20
			


		

		end)
	end)
end)

And this is where it is located:
image

1 Like

Clone the part and set its position to something else.

2 Likes

1/2 of the solution (Thanks!) But how do i make it pool when it touches the ground?

Use a touched event, and check to see if it is touching the baseplate.

And then what? Can you please send an example of a script?

You should be able to figure this out fine, but here:

bloodThingName.Touched:Connect(function(base)
if base.Name == "Baseplate" then
-- Put your blood spill code here
end
end)
2 Likes

How about using raycast.
Shoot a ray from the character, and create a thin cylinder object wherever it hits.

1 Like

Yeah, but what if its smooth terrain?

He could use a raycast, or put an invisible floor just on top of the terrain.

2 Likes

Whats a raycast (Sorry im very new)?

Here:

1 Like

Shoots a ray and returns what the ray hit.

1 Like

this post is from 2 years ago but i saw that the solution isnt something that helped you with how to make the blood splat i guess, and .Touched() wouldnt work well, heres a code that i made. For the script to work, you MUST insert a folder named ‘Blood’ in workspace

---| Services

local TweenService = game:GetService('TweenService')
local Players = game:GetService('Players')

---| Constants

local tweenInfoIn = TweenInfo.new(3, Enum.EasingStyle.Exponential, Enum.EasingDirection.Out)
local tweenInfoOut = TweenInfo.new(5, Enum.EasingStyle.Linear, Enum.EasingDirection.Out)
local ignored = {workspace.Blood}

---| Functions

function Raycast(origin, direction)
	local hit, rayPosition, normal = workspace:FindPartOnRayWithIgnoreList(Ray.new(origin, direction), ignored)
	if hit then
		local humanoid = hit.Parent:FindFirstChild('Humanoid') or hit.Parent.Parent:FindFirstChild('Humanoid')
		if humanoid then
			table.insert(ignored, humanoid.Parent)
			return Raycast(origin, direction)
		end
		return hit, rayPosition, normal
	end
end
function StartSplatHitbox(splatter)
	task.spawn(function()
		repeat wait()
			local hit, rayPosition, normal = Raycast(splatter.Position, splatter.Velocity.Unit * 5)
			if hit then
				local humanoid = hit.Parent:FindFirstChild('Humanoid')
				if not humanoid then
					local unit = splatter.Velocity.Unit.X * 100
					local size = Random.new():NextNumber(0.0035, 2)
					splatter.Anchored = true
					splatter.CFrame = CFrame.new(rayPosition, rayPosition - normal) * CFrame.Angles(math.rad(90), math.rad(unit), 0)
					TweenService:Create(splatter, tweenInfoIn, {Size = Vector3.new(size, size/8, size)}):Play() 

					task.delay(15, function()
						local tween = TweenService:Create(splatter, tweenInfoOut, {Transparency = 1})
						tween:Play()
						tween.Completed:Wait()
						splatter:Destroy()
					end)
				end
			end
		until splatter.Anchored
	end)
end

---| Main Program

Players.PlayerAdded:Connect(function(player)
	player.CharacterAdded:Connect(function(character)
		local humanoid = character:WaitForChild('Humanoid')
		local torso = character:WaitForChild('Torso')

		humanoid.Died:Connect(function()
			if character:FindFirstChild('Head') then
				character.Head:Destroy()

				for i = 1, math.random(200, 250) do
					local velocityX = Random.new():NextNumber(-10, 10)
					local velocityZ = Random.new():NextNumber(-10, 10)
					local velocity = torso.CFrame.UpVector * Random.new():NextNumber(10, 50) + Vector3.new(velocityX, 0, velocityZ)

					local bloodDrop = Instance.new('Part')
					bloodDrop.CanCollide = false
					bloodDrop.Color = Color3.fromRGB(128, 0, 0)
					bloodDrop.Material = Enum.Material.Slate
					bloodDrop.Size = Vector3.new(0.1, 0.5, 0.1)
					bloodDrop.Parent = workspace.Blood
					bloodDrop.CFrame = CFrame.new(torso.Position + torso.CFrame.UpVector * 0.5, Vector3.new(0, 90, 0))
					bloodDrop.Velocity = velocity
					bloodDrop.RotVelocity = velocity/2

					StartSplatHitbox(bloodDrop)

					task.wait()
				end
			end
		end)
	end)
end)

No way you actually replied after 2 years! I’m not even developing for roblox anymore! I’ve moved onto unity now. Thanks anyway!

2 Likes