Projectile not hitting/damaging anything

if Action == "E" then    
        local Sword = FX.Sword:Clone()
        Sword.Parent = workspace
        Sword.CFrame = HumRP.CFrame * CFrame.new(0,5,9)
        Sword.CFrame = CFrame.new(Sword.Position,MouseHit.p)
        
        delay(0.8,function()
        local Tween = TS:Create(Sword,TweenInfo.new(3),{CFrame = Sword.CFrame * CFrame.new(0,0,-130)})
        Tween:Play()
        
        Sword.Touched:Connect(function(Hit)
            if Hit.Name == "HumanoidRootPart" and Hit.Parent ~= Char then                                                    
            for i,v in pairs(workspace:GetDescendants()) do
                if v.Name == "HumanoidRootPart" and v.Parent ~= Char then
                    if (v.Position - Sword.Position).Magnitude < 10 then
                        local EHumpRP = v.
                        local EHum = v.Parent:FindFirstChild("Humanoid")
                        
                        EHum:TakeDamage(20)
                    end
                end
            end
                
                    Sword:Destroy()                        
            end    
        end)    
    end)    
        game.Debris:AddItem(Sword,2.5)
        
        delay(2.2,function()
            local Tween = TS:Create(Sword,TweenInfo.new(0.3),{Transparency = 1})
            Tween:Play()
        end)
    end    
end)

here’s a video that i followed Magic Projectile Part 1 [Roblox Tutorial] - Tweening, Mouse And More! - YouTube and also how do i add more projectiles to it with random positions?

Well this script barely makes any sense for me, because you are putting in so much effort while you can do it a lot simpler.

  1. You check if you hit a HumanoidRootPart, if the torso is hit it just gets destroyed.
  2. If it did hit a RootPart then it’ll damage all the players in a radius of 10.
  3. You made a variable which doesnt even get used local EHumpRP = v. as well as add a . at the end.

A much compacter script would be:

Sword.Touched:Connect(function(HitPart)
   local Humanoid = HitPart.Parent and HitParent.Parent:FindFirstChildWhichIsA("Humanoid")
   if HitPart.Parent ~= Char and Humanoid then
      Humanoid:TakeDamage(20)
   elseif HitPart.Parent ~= Char then
      Sword:Destroy()
   end
end)

If you want it to have an AoE (area of effect) then I highly suggest to make loop through the players instead of looping through the whole workspace (which will be very lagg). Only problem then is the AoE will not damage any NPCs, instead I suggest to make a folder for NPCs as well and loop through that as well.

1 Like

are you damaging on the client? also if you aren’t using raycasts ill rip your spine out

Thanks for telling me! I was kinda troubled since i just copied it.

I dont know. I’m really sorry lol im still learning from it what does it do though?