Hello,
So, I have this projectile that is cloned by enemy NPCs when the player (Workspace.Magna) is nearby. The only Issue I have is that not only does the projectile take an arced path and misses, but it sometimes registers as hitting the NPC itself with the console saying it could not find the Humanoid. If it helps, the projectile is cloned 3 studs above the NPC's right arm, since I do not know how to clone it to be always in front of the arm regardless of orientation. Perhaps this is not the most effective way to do this, for I am quite novice. Any help and tips are vastly appreciated !
local Debounce = false
local BodyPosition = script.Parent.BodyPosition
local magnapos = game.Workspace.Magna.PrimaryPart.Position
local Parent = script.Parent
local Debris = game:GetService("Debris")
local reachedtarget = false
BodyPosition.Position = magnapos
BodyPosition.ReachedTarget:Connect(function(gothim)
BodyPosition:Destroy()
Parent.Massless = false
reachedtarget = true
Debris:AddItem(Parent, 3)
end)
Parent.Touched:connect(function (hit)
if not Debounce and not reachedtarget then
Debounce = true
local humanoid = hit.Parent:findFirstChild("Humanoid")
if humanoid ~= nil then
humanoid:TakeDamage(2)
BodyPosition:Destroy()
Debounce = false
reachedtarget = false
Debris:AddItem(Parent, 3)
end
end
end)
Debris:AddItem(Parent, 1.5)
