Code
--create blood spot where shrapnel hit
local bloodStain = Instance.new("Part")
bloodStain.Massless = true
bloodStain.CanCollide = false
bloodStain.Size = Vector3.new(1, 1, 1)
bloodStain.Transparency = 1
local bloodStainDecal = Instance.new("Decal")
bloodStainDecal.Texture = "rbxassetid://149316462"
bloodStainDecal.Face = Enum.NormalId.Front
bloodStainDecal.Parent = bloodStain
--set cframe to hit's cframe (to match orientation)
bloodStain.CFrame = ray.Instance.CFrame
--set position to ray.Position
bloodStain.Position = ray.Position
--change bloodstain's orientation depending on the ray.Normal property
bloodStain.CFrame = CFrame.lookAt(ray.Position, ray.Position + ray.Normal)
--weld together
local bloodWeld = Instance.new("WeldConstraint")
bloodWeld.Part0 = ray.Instance
bloodWeld.Part1 = bloodStain
bloodWeld.Parent = bloodWeld.Part0
--parent bloodstain
bloodStain.Parent = ray.Instance
What it yields
I then added the line below right after the last CFrame change and right before the welding process
--change cframe for the last time by moving it back by half its size (based on its lookvector) as it juts out too far from the injury location
bloodStain.CFrame = bloodStain.CFrame * CFrame.new(-bloodStain.CFrame.LookVector * bloodStain.Size.X/2)
What this code now yields
Much better. It is completely flush against the body part and actually looks like it’s bleeding.
So what’s the problem?
Well, here’s what happens when I’m turned slightly:
It’s no longer flush.
What do I need to do to fix this? I assume it’s some sort of edit to the added line, which I will leave here again for a refresher:
--change cframe for the last time by moving it back by half its size (based on its lookvector) as it juts out too far from the injury location
bloodStain.CFrame = bloodStain.CFrame * CFrame.new(-bloodStain.CFrame.LookVector * bloodStain.Size.X/2)