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

i made a logia script from one piece but it doesn't stop damage from happening help plz?

Asked by 3 years ago
local character = script.Parent -- we put our character inside a variable

local bodyParts = {"Head", "UpperTorso", "LowerTorso", "RightUpperArm", "RightLowerArm", "RightHand", "LeftUpperArm", "LeftLowerArm", "LeftHand", "RightUpperLeg", "RightLowerLeg", "RightFoot", "LeftUpperLeg", "LeftLowerLeg", "LeftFoot"} -- a table which holds the name of those bodyparts which are affected by the logia

function Logia(limb, color, material, transparency, particle) -- a function which requires the bodypart (first argument), the color (second), material, transparency and a particle

    local part = limb -- we declare the limb as a part within this function (i did that because i had tried to script this at the beginning but failed and to avoid replacing every spot where i used "part" instead of "limb" i did it this way)

    local x = Instance.new("IntValue", part) -- an intvalue inside the affected part (this indicates a cooldown, means as long as this value exists a limb it cant be affected again, to avoid glitches etc...)
    x.Name = "LogiaEffect" -- we give it a name
    game.Debris:AddItem(x, 1) -- we destroy it after 1 second
    local x2 = Instance.new("IntValue",character) -- we create another value inside the character this time (this one shows the buso haki script that this person is using the logia affect right now)
    x2.Name = "LogiaEffectThereforeNoBuso" -- we give it a name
    game.Debris:AddItem(x2, 1) -- we destroy it after 1 second

    spawn(function() -- the code below will be ran without interrupting the rest (means if we have a wait inside this it wont pause the whole script but only the part inside)

        local formerColor = Instance.new("BrickColorValue", script) -- we create a brick color value inside this logia script
        formerColor.Value = part.BrickColor -- which holds the former color of our logia affected bodypart to restore it later

        local formerShirt -- we create an empty value which will hold the former shirt value
        if not script:FindFirstChild("FormerShirt") and character:FindFirstChild("Shirt") then -- we check if theres no former shirt value but the player wears a shirt, if so then...
            formerShirt = Instance.new("StringValue", script) -- we create a string value inside the script and set it equal with our formerly empty shirt value in line 21
            formerShirt.Name = "FormerShirt" -- we give our value a name
            formerShirt.Value = character:FindFirstChild("Shirt").ShirtTemplate -- we make the value store the shirt id
            character:FindFirstChild("Shirt").ShirtTemplate = "" -- we make the shirt of our player blank, so he/she looks topless (necessary for the logia affect)
        elseif script:FindFirstChild("FormerShirt") and character:FindFirstChild("Shirt") then -- if theres already a shirt value and the player wears a shirt then..
            formerShirt = script:FindFirstChild("FormerShirt") -- we set the shirtvalue equal with the shirt variable in line 21
            character:FindFirstChild("Shirt").ShirtTemplate = "" -- we make the shirt of our player blank, so he/she looks topless (necessary for the logia affect)
        end

        local formerPants -- we create an empty value which will hold the former pants value
        if not script:FindFirstChild("FormerPants") and character:FindFirstChild("Pants") then -- we check if theres no former pants value but the player wears a shirt, if so then...
            formerPants = Instance.new("StringValue", script) -- we create a string value inside the script and set it equal with our formerly empty pants value in line 32
            formerPants.Name = "FormerPants" -- we give our value a name
            formerPants.Value = character:FindFirstChild("Pants").PantsTemplate -- we make the value store the pants id
            character:FindFirstChild("Pants").PantsTemplate = "" -- we make the pants of our player blank, so he/she looks pantless (necessary for the logia affect)
        elseif script:FindFirstChild("FormerPants") and character:FindFirstChild("Pants") then
            formerPants = script:FindFirstChild("FormerPants") -- we set the pantsvalue equal with the shirt variable in line 32
            character:FindFirstChild("Pants").PantsTemplate = ""  -- we make the pants of our player blank, so he/she looks pantless (necessary for the logia affect)
        end

        if particle ~= nil then -- if a particle was given then
            particle.Parent = part -- we put the particle inside the affected bodypart
        end
        part.BrickColor = BrickColor.new(color) -- we set the desired color
        part.Material = material -- we set the desired material
        part.Transparency = transparency -- we set the desired transparency

        wait(1) -- we wait 1 second (the time which indicates how long the affect will last)

        if particle ~= nil then -- if a particle was given then
            particle:Destroy() -- we destroy the particle
        end
        part.BrickColor = formerColor.Value -- we restore the bodypart's color
        part.Material = "SmoothPlastic" -- we restore the bodypart's material
        part.Transparency = 0 -- we restore the bodypart's transparency

        if character:FindFirstChild("Shirt") then -- if the player has a shirt then...
            character:FindFirstChild("Shirt").ShirtTemplate = formerShirt.Value -- we restore the shirtid (the shirt in general)
        end
        if character:FindFirstChild("Pants") then -- if the player has pants then...
            character:FindFirstChild("Pants").PantsTemplate = formerPants.Value -- we restore the pantsid (the pants in general)
        end

    end)

end
print("test")
for _, limb in pairs(character:GetChildren())do -- we loop through the character
    for __, bPart in pairs(bodyParts)do -- we loop through the affected bodyparts table
        if limb.Name == bPart then -- if theres a bodypart inside our character which is affected, because the same name appears in the table in line 3 then...
            limb.Touched:Connect(function(hit) -- we check if it has been hit
                if hit.Parent:FindFirstChild("Humanoid") or hit:FindFirstChild("Attack") then -- if the person who hit has a humanoid or the thing it his has a special value which indicates the hit whatsoever has an attack (for example: we have the cases, that the player touches the ground which also means that it was hit by hit but not with the intention to attack. therefore we should have a value inside the ground which indicates whether its an attack or not)
                    if not hit.Parent:FindFirstChild("UsingBuso") then -- if the hit person uses no buso then
                        if not limb:FindFirstChild("LogiaEffect") then -- if the touched bodypart has no cooldown then
                            local particle = game:GetService("ReplicatedStorage"):WaitForChild("Flame"):Clone() -- we clone the smoke particle
                            print("test 2")
                            Logia(limb, "Neon Orange", "Neon", 0.1, particle) -- we call the function with the desired bodypart, then the color, the material, the transparency and the particle
                        end
                    end
                end
            end)
        end
    end
end
0
any errors? Gmorcad12345 434 — 3y
0
nah wyatt447 16 — 3y

Answer this question