Raycast blood not hitting anything

I wanted to make a blood spray system but it dosent work
The Raycast do not detect wall for some reason!
I already tried changing to CFrame.Position to Position again

wait()
local Humanoid = script.Parent.Humanoid
local OldHealth = Humanoid.Health
local bloodfloordecals = {4752637565, 4752637738, 4752637338}
local bloodwalldecals = {10189551013, 10189213706, 10189219071}
local dir = Vector3.new(-1, 0, 0) * 120
local size = Vector3.new(math.random(0.5, 2), math.random(0.5, 2), 0)
local d = {}

for i,v in pairs(game.Workspace.NPCs:GetDescendants()) do
	if v:IsA("BasePart") then
		table.insert(d, v)
	end
end

function raycast(origin, direction, blacklist)
	local params = RaycastParams.new()
	params.FilterDescendantsInstances = blacklist
	params.FilterType = Enum.RaycastFilterType.Blacklist
	params.IgnoreWater = true
	
	workspace:Raycast(origin, direction, params)
end

function bloodspray(npc)
	local ray = raycast(npc.HumanoidRootPart.Position, Vector3.new(0, -1, 0) * 30, d)
	if ray then
		for i = 1,math.random(2,4) do
		local part = Instance.new("Part", workspace.Blood)
		part.CFrame = CFrame.new(ray.Position, ray.Position + ray.Normal) * CFrame.Angles(math.rad(90),0,0)
		part.Anchored = true
		part.Size = size
		part.CanCollide = false
		local decal = Instance.new("Decal", part)
		decal.Face = Enum.NormalId.Front
		decal.Texture = "http://www.roblox.com/asset/?id="..bloodfloordecals[math.random(1, #bloodfloordecals)]
		decal.Color3 = Color3.new(0.27451, 0.0588235, 0.0588235) 
		end
	end
end

function bloodspraywall(npc)
	local ray = raycast(npc.HumanoidRootPart.CFrame.lookVector, Vector3.new(0, 0, -1) * 10, d)
	if ray then
		for i = 1,math.random(2,4) do
			local part = Instance.new("Part", workspace.Blood)
			part.CFrame = CFrame.new(ray.Position, ray.Position + ray.Normal) * CFrame.Angles(math.rad(90),0,0)
			part.Anchored = true
			part.Size = size
			part.CanCollide = false
			local decal = Instance.new("Decal", part)
			decal.Face = Enum.NormalId.Front
			decal.Texture = "http://www.roblox.com/asset/?id="..bloodwalldecals[math.random(1, #bloodwalldecals)]
			decal.Color3 = Color3.new(0.52549, 0.52549, 0.52549) 
		end
	end
end

Humanoid:GetPropertyChangedSignal("Health"):Connect(function()
	if Humanoid.Health < OldHealth then
		bloodspray(script.Parent)
		bloodspraywall(script.Parent)
		wait(0.5)
	end

	OldHealth = Humanoid.Health
end)

2 Likes

nvm iam just goofy aaaaaaaaaaaaaaaaaaaaaaaaaa

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