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)
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.
You check if you hit a HumanoidRootPart, if the torso is hit it just gets destroyed.
If it did hit a RootPart then it’ll damage all the players in a radius of 10.
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.