Errors with raycasting for blood splatter system

  1. What do you want to achieve?
    I’m trying to make a blood splatter effect.

  2. What is the issue?
    My code seems to be working weird, once I create the particle for the effect, it is supposed to send a raycast each RunService.Heartbeat, half the times the raycast works, and half it doesnt. Even when it does work sometimes only the raycast of 2 out of 4 particles hits. (I’m creating 4 particles, but all of them are going on the same direction, shouldn’t be the issue tho, since even with all of them going on different directions it wont work)

Server Script

local BloodModule = require(game.ReplicatedStorage.ModuleScript)

while wait(2) do
	BloodModule.BloodEffect(script.Parent.HumanoidRootPart, 4)

Module script

local TweenService = game:GetService("TweenService")

local module = {}

function module.BloodEffect(Origin, PartAmount)
	for Count = 1, PartAmount do
		local particle = script.BloodPart:Clone()
		particle.Anchored = false
		particle.CanCollide = false
		particle.Position = Origin.Position
		particle.Parent = workspace.Visuals
		particle.Velocity =, 23, 12)
		game.Debris:AddItem(particle, 3)

			local rayParams =
			rayParams.IgnoreWater = true
			rayParams.FilterType = Enum.RaycastFilterType.Blacklist
			rayParams.FilterDescendantsInstances = {particle, Origin.Parent}

			local raycastResult = workspace:Raycast(particle.Position + particle.Size,,-1,0), rayParams) 
			if raycastResult then
				if raycastResult.Instance.Transparency < 1 then
					local xy = math.random(3, 4)
					local splatter = script.BloodSplatter:Clone()
					splatter.Parent = workspace.Visuals
					game.Debris:AddItem(splatter, 2.7)

					TweenService:Create(splatter,, Enum.EasingStyle.Linear), {Size =, xy, 0.05)}):Play()
					splatter.CFrame =, particle.Position + raycastResult.Normal)	
					local Tween = TweenService:Create(splatter.blood,, Enum.EasingStyle.Linear), {Transparency = 1}):Play()
					local Tween2 = TweenService:Create(splatter.Decal,, Enum.EasingStyle.Linear), {Transparency = 1}):Play()

return module

Hope someone can explain why this is happening, I’m somewhat of a beginner to LUA.