Hi, I’m trying to improve my blood system that uses raycast to detect if it hit a wall, floor, etc. When I tried making it rotate accordingly to the surface, I found out that the raycast is not ignoring the items in the ignore list. Heres the code:
--<<{{Blood Variables}}>>--
local Humanoid = script.Parent:FindFirstChildOfClass("Humanoid")
local BloodParts = game.ReplicatedStorage.BloodParts
local BloodDB = true
--<<{{Scripting}}>>--
local CurrentHealth = script.Parent.Humanoid.Health
script.Parent.Humanoid.Changed:Connect(function()
wait(0.1)
if script.Parent.Humanoid.Health < CurrentHealth then
if BloodDB == true then
BloodDB = false
for i = 1,math.random(1,CurrentHealth-Humanoid.Health/2) do
local RandomBlood = BloodParts:GetChildren()[math.random(1,#BloodParts:GetChildren())]
local Blood = RandomBlood:Clone()
Blood.Parent = workspace.Blood
Blood.Name = script.Parent.Name
local Particle = script.Blood:Clone()
Particle.Parent = script.Parent.Torso
Particle:Emit(1)
local raycastParams = RaycastParams.new()
raycastParams.FilterType = Enum.RaycastFilterType.Blacklist
raycastParams.FilterDescendantsInstances = {workspace.Blood,workspace.Water,workspace.Bullets,script.Parent,script.Parent.Weapon,script.Parent.PrimaryPart}
local ray = workspace:Raycast(script.Parent:FindFirstChild("HumanoidRootPart").Position,Vector3.new(math.random(-4.5,4.5),-100,math.random(-4.5,4.5)),raycastParams)
local part = ray.Instance
local position = ray.Position
local normal = ray.Normal
Blood.PrimaryPart.CFrame = CFrame.new(position)
Blood.PrimaryPart.CFrame = CFrame.new(Blood.PrimaryPart.Position,Blood.PrimaryPart.Position+normal)
Blood.PrimaryPart.Orientation = Vector3.new(0,math.random(-180, 180),0)
game:GetService("Debris"):AddItem(Blood, 10)
wait()
end
wait()
BloodDB = true
end
end
CurrentHealth = script.Parent.Humanoid.Health
end)
Help is appriciated!