I’m currently working on a script where blood comes out of the character in chunks and is supposed to splatter when it comes into contact with an object (wall,ground) the issue is that the blood only splatters occasionally and usually the chunk just goes straight through the object and the hit detection doesn’t work, sorry if this is hard to understand I suck at explaining things.
here’s the main code:
while true do
wait(math.random(0,0.8))
local blood = game.ServerStorage:WaitForChild(“Meatball”):Clone()
blood.Parent = character.Head
debris:AddItem(blood,1)
if speed > 3 then
blood.Transparency = 0
offset = -4.5
else
blood.Transparency = 0
offset = 0
end
blood.CFrame = character.Torso.CFrame * CFrame.new(0,1.5,offset)
local bv = Instance.new("BodyVelocity", blood)
bv.MaxForce = Vector3.new(3000,3000,3000)
bv.P = 100 --1000
bv.Velocity = Vector3.new(math.random(-15,30),math.random(-15,30),math.random(-15,30))
wait()
bv.MaxForce = Vector3.new(0,0,0)
bv.P = 0
bv.Velocity = Vector3.new(0,0,0)
local connection
function onTouched(hit)
if hit.Parent:FindFirstChild("Humanoid") == nil and hit.Parent.Parent:FindFirstChild("Humanoid") == nil then
blood.Anchored = true
blood.Transparency = 1
local dist = math.random(1, 2)
local rays = {
rayforward = Ray.new(blood.Position, blood.CFrame.lookVector * dist),
raybackward = Ray.new(blood.Position, blood.CFrame.lookVector * -dist),
rayright = Ray.new(blood.Position, blood.CFrame.RightVector * dist),
rayleft = Ray.new(blood.Position, blood.CFrame.RightVector * -dist),
raydown = Ray.new(blood.Position, blood.CFrame.UpVector * -dist),
rayup = Ray.new(blood.Position, blood.CFrame.UpVector * dist)
}
for i,ray in pairs(rays) do
local hit, pos, normal = game.Workspace:FindPartOnRay(ray, character)
if hit and hit.Parent:FindFirstChild("Humanoid") == nil and hit.Parent.Parent:FindFirstChild("Humanoid") == nil and hit.Name ~= "Splatter" then
local splatter = game.ServerStorage.Splatter:GetChildren()[math.random(1,2)]:Clone()
local dropsize = math.random(dropsizemin * 10,dropsizemax *10) / 10
splatter.Parent = game.Workspace
splatter.CFrame = CFrame.new(pos, pos + normal) * CFrame.Angles(math.rad(-90), 0, 0) * CFrame.Angles(0, math.rad(math.random(1, 360)), 0) * CFrame.new(0, 0.04, 0)
ts:Create(splatter, tweeninfo, {Size = Vector3.new(dropsize, 0.10,dropsize)}):Play()
debris:AddItem(splatter,5)
end
end
connection:Disconnect()
end
end
connection = blood.Touched:Connect(onTouched)
wait()
https://www.roblox.com/games/6185974488/Blood-Test?refPageId=dfe32dff-2db3-48d9-8d69-be5f14ac2e41