Using this script, i need hep to find a way to make the raycast not collide with the legs as it causes the duplicated blood part to float where the legs were, i tried some ways but i have absolutly no idea how to do it
Script:
local Players = game:GetService(“Players”)
local Player = Players.LocalPlayer
local steps = 0.1
local function createBloodSplatter(damagePosition)
local blood = game.Workspace:FindFirstChild(“Blood1”)
if blood == nil then
warn(“Could not find a Part named ‘Blood’ in Workspace.”)
return
end
blood = blood:Clone()
blood.Name = “BloodSplatter”
local sizeOptions = {
Vector3.new(blood.Size.X, 0.1, 0.3),
Vector3.new(blood.Size.X, 0.1, 0.3),
Vector3.new(blood.Size.X, 0.1, 0.3)
}
local selectedSize = sizeOptions[math.random(1, #sizeOptions)]
blood.Size = selectedSize
-- Use a ray to find the surface where the blood splatter should be attached
local ray = Ray.new(damagePosition, Vector3.new(0, -1, 0) * 10)
local part, hitPos, surfaceNormal = workspace:FindPartOnRay(ray)
if part == nil then
-- If no surface is found, use the default position
blood.Position = Vector3.new(damagePosition.X, steps, damagePosition.Z)
else
-- Attach the blood splatter to the surface and align it with the surface normal
blood.CFrame = CFrame.new(hitPos, hitPos + surfaceNormal) * CFrame.Angles(math.rad(-90), 0, 0)
end
blood.Parent = game.Workspace
wait(400)
blood:Destroy()
end
local function onPlayerAdded(player)
player.CharacterAdded:Connect(function(character)
character.Humanoid.Died:Connect(function()
createBloodSplatter(character.HumanoidRootPart.Position)
end)
character.Humanoid.HealthChanged:Connect(function(health)
if health <= 0 then
return
end
createBloodSplatter(character.HumanoidRootPart.Position)
end)
end)
end
Players.PlayerAdded:Connect(onPlayerAdded)
(also sorry if is pretty unoptimized im not a experienced scripter)