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

[SOLVED] Why does this projectile keep damaging the user?

Asked by
soutpansa 120
7 years ago
Edited 7 years ago

I have a script that puts a big shockwave at the players feet when they press x. It works fine, damage is working and it does exactly what I want it to, except the fact that it hurts the user too! I've tried everything I can to make it not damage the user, but I can't seem to make it work, here are the scripts that it uses:

local Player = game.Players.LocalPlayer 
local mouse = Player:GetMouse() 
local lastUse = 0;


local function onKeyDown(key) 
    local Key = key:lower()
    if key == "x" and Player.Levelss.Level.Value >= 30 and tick()-lastUse > 10  then 
        local x = Instance.new("Part")
        x.BrickColor = BrickColor.new("White")
        x.Material = "Neon"
        x.CanCollide = false
        x.Transparency = 0.6
        x.Size = Vector3.new(80,1,80)
        x.TopSurface = "Smooth"
        x.BottomSurface = "Smooth"
        x.Shape = "Block"
        x.Anchored = true
        x.Name = Player.Name
        local m = Instance.new("CylinderMesh")
        m.Parent = x
        local fd = script.fireDamage:clone()
        fd.Parent = x
        local a = Instance.new("Sound")
        a.SoundId = "http://www.roblox.com/asset/?id=165970126"
        a.Parent = x
        a.Volume = 2
        a:play()




        x.CFrame = Player.Character.Torso.CFrame*CFrame.new(0, -2.3 , 0)
        x.Parent = Workspace  
        game.Debris:AddItem(x, 6)

        lastUse = tick(); 
    end
end


mouse.KeyDown:connect(onKeyDown)

Damage (fd) script:

function onDamage(Part)
    if Part.Parent:FindFirstChild("Humanoid") ~= nil and Part.Parent.Name ~= "script.Parent.Name" then




            Part.Parent.Humanoid.Health = Part.Parent.Humanoid.Health - script.Damage.Value
            wait(0.05)
        end
        Part.Parent.Humanoid.Sit = true


    end
    wait(0.025)


script.Parent.Touched:connect(onDamage)

Please help me get to the bottom of this, thanks ^^

0
On line 2 of your damage script, script.Parent.Name should not be within quotes. Pyrondon 2089 — 7y
0
Oh XD. Thank you very much. soutpansa 120 — 7y
0
If pyrondon gave you the solution, you should put [SOLVED] in the titel and give him an upvote ;) RubenKan 3615 — 7y

Answer this question