Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How is this AOE damaging the player that cast it and the NPC?

Asked by 4 years ago

This is damaging both the player that casts it and the NPC. I am clueless, I checked to see if it hits the player.Character or the Humanoid of the NPC which I renamed "NPC".

Event.OnServerEvent:Connect(function(player)
    local character = player.Character
    local Humanoid = character.Humanoid
     local BV = Instance.new("BodyVelocity",character.HumanoidRootPart)
    BV.MaxForce = Vector3.new(math.huge,math.huge,math.huge)
    BV.Velocity = character.HumanoidRootPart.CFrame.lookVector*0.05
    game.Debris:AddItem(BV,.1)
    wait(.1)
    local Ice = Instance.new("Part",character)
    Ice.Anchored = true
    Ice.CanCollide = false
    Ice.Shape = "Cylinder"
    Ice.Material = "Ice"
    Ice.BrickColor = BrickColor.new("Cyan")
    Ice.Transparency = .7
    Ice.Size = Vector3.new(.1,.1,.1)
    Ice.CFrame = character.HumanoidRootPart.CFrame+Vector3.new(0,-2,0)
    Ice.Orientation = Vector3.new(0,0,90)
    Ice.Touched:Connect(function(hit)
    if hit.Parent == character then return end
    if hit.Parent:FindFirstChild("NPC") and debounce == false then
        debounce = true
        local dmg = script.damage.Value
        local ehumanoid = hit.Parent.NPC
        ehumanoid:TakeDamage(dmg)
    end
end)

    local Tw1 = TweenInfo.new(.5,Enum.EasingStyle.Linear,Enum.EasingDirection.Out,0,false,0)
    local properties = {Size = Vector3.new(1,80,80);Transparency = .6}
    local Tween = TweenService:Create(Ice,Tw1,properties);
    Tween:Play()
    wait(.3)
    local Tw2 = TweenInfo.new(.5,Enum.EasingStyle.Linear,Enum.EasingDirection.In,0,false,1)
    local properties2 = {Size = Vector3.new(1,10,10);Transparency = .8}
    local Tween2 = TweenService:Create(Ice,Tw2,properties2)
    Tween2:Play() 
    wait(2)
    debounce = false
end)
0
try adding if ehumanoid ~= Humanoid then ehumanoid:TakeDamage(dmg) end by replacing line 24 and 25 with this SimpleFlame 255 — 4y
0
hmm, you would think that should work, oddly it is still damaging both player and NPC. Dorchsaoil 11 — 4y
0
Thank you though. Dorchsaoil 11 — 4y
0
I got it fixed, although it seems like a strange fix. I parented the AOE to the workspace rather than the player and that worked. I dunno. LOL Dorchsaoil 11 — 4y

Answer this question