Blood sometimes doesnt appear

what I want to achieve is a blood projectile hitting something and then blood splattering on the hit point.

I’ve already achieved what I wanted, however sometimes when a blood projectile hits the floor, no blood splatters.

I have tried fixing it myself but have come to no avail.

The touched script :

local done = false

script.Parent.Touched:Connect(function(hit)
	if hit.Name ~= script.Parent.Name then
		if done == false then
			done = true
			script.Parent.CanTouch = false
			script.Parent.CanCollide = false
			game.ReplicatedStorage.BloodEvent:Fire(script.Parent)
			task.wait(1)
			script.Parent:Destroy()
		end
	end
end)

splattering script

local ts = game:GetService("TweenService")

game.ReplicatedStorage.BloodEvent.Event:Connect(function(parent)
	local randomnum = math.random(0.5,1.25)
	local part = Instance.new("Part")
	part.Name = "BloodPart"
	part.Size = Vector3.new(0.5,0.1,0.5)
	part.Anchored = true
	part.Material = Enum.Material.SmoothPlastic
	part.CanTouch = false
	part.CanCollide = false
	part.Transparency = 0
	part.Orientation = Vector3.new(0,math.random(0,180),0)
	part.BrickColor = BrickColor.new("Dark red")
	parent.Anchored = true

	local raycastParams = RaycastParams.new()
	raycastParams.FilterDescendantsInstances = {game.Workspace.Blood}
	raycastParams.FilterType = Enum.RaycastFilterType.Exclude
	local result = workspace:Raycast(parent.Position + Vector3.new(0,10,0), Vector3.new(0,-50,0), raycastParams)
	if result then
		part.Parent = game.Workspace.Blood.ActualBlood
		part.Position = result.Position + Vector3.new(0,part.Size.Y,0)
		ts:Create(part,TweenInfo.new(0.1,Enum.EasingStyle.Quad,Enum.EasingDirection.Out),{Size = Vector3.new(3,0.1,3)*randomnum}):Play()
	end
end)

any help would be greatly appreciated.

Hello! I adjusted some code and I think it should work now.

local done = false
wait(2)

script.Parent.Touched:Connect(function(hit)
	if game.Players:FindFirstChild(hit.Parent.Name) then
		if done == false then
			done = true
			script.Parent.CanTouch = false
			script.Parent.CanCollide = false
			game.ReplicatedStorage.BloodEvent:FireAllClients(hit.Parent.Name, script.Parent, script.Parent.Position)
			task.wait(1)
			script.Parent:Destroy()
		end
	end
end)
local ts = game:GetService("TweenService")

game.ReplicatedStorage.BloodEvent.OnClientEvent:Connect(function(plrName, oldPart, oldPartPos)
	if plrName == game.Players.LocalPlayer.Name then
		wait(0.2)
		local randomnum = math.random(0.5,1.25)
		local part = Instance.new("Part",workspace.Blood)
		part.Name = "BloodPart"
		part.Size = Vector3.new(0.5,0.1,0.5)
		part.Anchored = true
		part.Material = Enum.Material.SmoothPlastic
		part.CanTouch = false
		part.CanCollide = false
		part.Transparency = 0
		part.Orientation = Vector3.new(0,math.random(0,180),0)
		part.BrickColor = BrickColor.new("Dark red")

		local raycastParams = RaycastParams.new()
		local toIgnore = {game.Workspace.Blood, oldPart}
		for e = 1,#game.Players:GetChildren() do
			if game.Players:GetChildren()[e].Character then
				table.insert(toIgnore,game.Players:GetChildren()[e].Character)
			end
		end
		raycastParams.FilterDescendantsInstances = toIgnore
		raycastParams.FilterType = Enum.RaycastFilterType.Exclude
		local result = workspace:Raycast(Vector3.new(oldPartPos.X,oldPartPos.Y+10,oldPartPos.Z), Vector3.new(0,-50,0), raycastParams)
		if result then
			part.Parent = game.Workspace.Blood.ActualBlood
			part.Position = result.Position + Vector3.new(0,part.Size.Y,0)
			ts:Create(part,TweenInfo.new(0.1,Enum.EasingStyle.Quad,Enum.EasingDirection.Out),{Size = Vector3.new(3,0.1,3)*randomnum}):Play()
		end
	end
end)

still some of the projectiles dont splatter.

i fixed it! it turns out the projectiles did splatter BUT i was multiplying the size by 0.5 which then makes the part have the size of 0. thanks still tho.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.