You can write your topic however you want, but you need to answer these questions:
-
What do you want to achieve? Keep it simple and clear!
-
What is the issue? The parts are spawning mid air as they attach to players and other npc’s but as those two things move, the part is left floating
-
What solutions have you tried so far? Tried rewriting it and trying to detect if the praent of the part doesn’t have a humanoidrootpart as a child
THE SCRIPT IS STORED IN SERVERSCRIPTSERVICE
local bloodsplats = {"116830967","116830967","116830967","116830967" }
local human = script.Parent:WaitForChild("Humanoid")
human.HealthChanged:Connect(function()
local headcf = script.Parent.Head.CFrame
for i = 1,5 do
local a = Instance.new("Part",nil)
a.Size = Vector3.new(math.random(1,3.5),math.random(1,3.5),0.05)
a.Transparency = 0
a.CanCollide = false
a.Anchored = true
a.Color = Color3.new(1, 0, 0)
local decal = Instance.new("Decal",a)
decal.Texture = "rbxassetid://0"
local dir = Vector3.new(math.random(-50,50),math.random(-50,50),math.random(-50,50)).Unit * 20
local ray = Ray.new(headcf.Position,dir)
local part,pos,normal = workspace:FindPartOnRay(ray,script.Parent,false,true)
if part ~= nil then
a.CFrame = CFrame.new(pos,pos + normal)
a.Parent = workspace
end
game:GetService("Debris"):AddItem(a,10)
end
end)
EXAMPLE