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

how do i make something not damage me when it is run?

Asked by
Nosteal 50
9 years ago

here is the script:

-- REMEMBER, MAKE A TOOL AND PUT THIS IN THE TOOL.
Player = game.Players.LocalPlayer
repeat wait() until Player.Character ~= nil
Char = Player.Character
Torso = Player.Character.Torso
Mouse = Player:GetMouse()
me = script.Parent.Parent.Parent
cooldown = 100
Attack = false 
    Casting0 = Instance.new("Part")
    Casting = Instance.new("Decal")
    Casting2 = Instance.new("Decal")
    Casting3 = Instance.new("BodyAngularVelocity")
    Casting4 = Instance.new("Fire")
    Casting5 = Instance.new("CylinderMesh")
function WaterKick(key)
    key = key:lower()
    if key == "v" and Attack == false then
        Attack = true
        local TorsoCF = Torso.CFrame
        for i = 1, 100 ,3 do
            WaterKick = Instance.new("Part")
            WaterKick.Parent = game.Workspace
        WaterKick.Name = "WaterKick"
            WaterKick.Size = Vector3.new (math.random(4,6),math.random(4,6),math.random(4,6))
            WaterKick.Anchored = true
            WaterKick.TopSurface = 0    
            WaterKick.BottomSurface = 0
            WaterKick.CanCollide = false
            WaterKick.BrickColor = BrickColor.new("Bright blue")
            WaterKick.Transparency = 0.5
            WaterKick.CFrame = TorsoCF * CFrame.new(0,0,-i) * CFrame.Angles(math.random(),math.random(),math.random())
    -- For the Casting circle
    Casting0.Parent = game.Workspace.WaterKick
    Casting0.Transparency = 0
    Casting0.Name = "Casting0"
    Casting0.Size = Vector3.new(15,0.2,15)
    Casting0.Transparency = 1
    Casting0.CFrame = Torso.CFrame * CFrame.new(0,-3,0)
    Casting0.CanCollide = false
    Casting0.Anchored = true
    Casting0.BrickColor = BrickColor.new("Deep blue")
    Casting.Parent = game.Workspace.WaterKick.Casting0
    Casting.Name = "Casting"
    Casting.Texture = "http://www.roblox.com/asset/?id=199910011"
    Casting.Face = "Top"
    Casting2.Parent = game.Workspace.WaterKick.Casting0
    Casting2.Name = "Casting"
    Casting2.Texture = "http://www.roblox.com/asset/?id=199910011"
    Casting2.Face = "Bottom"
    Casting3.Parent = game.Workspace.WaterKick.Casting0
    Casting3.P = 2000
    Casting4.Parent = game.Workspace.WaterKick.Casting0
    Casting4.Size = 10
    Casting4.Heat = 25
    Casting4.Color = Color3.new(0,0,255)
    Casting4.SecondaryColor = Color3.new(0,0,255)
    Casting5.Parent = game.Workspace.WaterKick.Casting0



            WaterKick.Touched:connect(function(hit)
                Damage = hit.Parent:FindFirstChild("Humanoid")
                if Damage ~= nil and Damage ~= me then
                    Damage.Health = Damage.Health - "4"
                end
            end)
            game.Debris:AddItem(WaterKick,2)
            game.Debris:AddItem(Casting0,2)
        end
        wait(cooldown)
        Attack = false
    end 
end


Mouse.KeyDown:connect(WaterKick)

I tried to make it so if it hits you, it doesn't damage you. But, the script itself damages me when it is run. Here's what the script is supposed to do: it is supposed to make a kamehameha-ish thing that only damages different players that touch it, but instead it damages anyone who touches it (including the person who used it).

0
Updated the script. HungryJaffer 1246 — 9y

1 answer

Log in to vote
0
Answered by 9 years ago
-- REMEMBER, MAKE A TOOL AND PUT THIS IN THE TOOL.
Player = game.Players.LocalPlayer
repeat wait() until Player.Character ~= nil
Char = Player.Character
Torso = Player.Character.Torso
Mouse = Player:GetMouse()
me = script.Parent.Parent.Parent
cooldown = 100
Attack = false 
    Casting0 = Instance.new("Part")
    Casting = Instance.new("Decal")
    Casting2 = Instance.new("Decal")
    Casting3 = Instance.new("BodyAngularVelocity")
    Casting4 = Instance.new("Fire")
    Casting5 = Instance.new("CylinderMesh")
function WaterKick(key)
    key = key:lower()
    if key == "v" and Attack == false then
        Attack = true
        local TorsoCF = Torso.CFrame
        for i = 1, 100 ,3 do
            WaterKick = Instance.new("Part")
            WaterKick.Parent = game.Workspace
        WaterKick.Name = "WaterKick"
            WaterKick.Size = Vector3.new (math.random(4,6),math.random(4,6),math.random(4,6))
            WaterKick.Anchored = true
            WaterKick.TopSurface = 0    
            WaterKick.BottomSurface = 0
            WaterKick.CanCollide = false
            WaterKick.BrickColor = BrickColor.new("Bright blue")
            WaterKick.Transparency = 0.5
            WaterKick.CFrame = TorsoCF * CFrame.new(0,0,-i) * CFrame.Angles(math.random(),math.random(),math.random())
    -- For the Casting circle
    Casting0.Parent = game.Workspace.WaterKick
    Casting0.Transparency = 0
    Casting0.Name = "Casting0"
    Casting0.Size = Vector3.new(15,0.2,15)
    Casting0.Transparency = 1
    Casting0.CFrame = Torso.CFrame * CFrame.new(0,-3,0)
    Casting0.CanCollide = false
    Casting0.Anchored = true
    Casting0.BrickColor = BrickColor.new("Deep blue")
    Casting.Parent = game.Workspace.WaterKick.Casting0
    Casting.Name = "Casting"
    Casting.Texture = "http://www.roblox.com/asset/?id=199910011"
    Casting.Face = "Top"
    Casting2.Parent = game.Workspace.WaterKick.Casting0
    Casting2.Name = "Casting"
    Casting2.Texture = "http://www.roblox.com/asset/?id=199910011"
    Casting2.Face = "Bottom"
    Casting3.Parent = game.Workspace.WaterKick.Casting0
    Casting3.P = 2000
    Casting4.Parent = game.Workspace.WaterKick.Casting0
    Casting4.Size = 10
    Casting4.Heat = 25
    Casting4.Color = Color3.new(0,0,255)
    Casting4.SecondaryColor = Color3.new(0,0,255)
    Casting5.Parent = game.Workspace.WaterKick.Casting0



            WaterKick.Touched:connect(function(hit)
                Damage = hit.Parent:FindFirstChild("Humanoid")
                if Damage ~= nil and Damage.Parent ~= me.Character then -- It is here where you tried to compare a humanoid to a model.
                    Damage.Health = Damage.Health - "4"
                end
            end)
            game.Debris:AddItem(WaterKick,2)
            game.Debris:AddItem(Casting0,2)
        end
        wait(cooldown)
        Attack = false
    end 
end


Mouse.KeyDown:connect(WaterKick)

So here's what's happening. I'm going to take a shot in the dark and say that "me" is defined as the player's character. If this is so, then it will always return false since you're trying to compare Damage, a humanoid, to a character. The humanoid is not the character. If so, we can easily fix this by going to line 64, where we tried to compare it, and change it to Damage.Parent, since Damage is a humanoid, and getting it's parent will return the character. Then, we will be able to check if a character is being compared to a character.

UPDATE

Since I was told that me is actually the player, not the character, I have edited that line to get the Player's Character.

0
me is supposed to be like localplayer. Nosteal 50 — 9y
Ad

Answer this question