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

? about a fly again just with particles

Asked by 8 years ago

Okay, so i know that this kills me cause of the ClearAllChildren part in the Torso but i don't know what to do to change that any help there is appreciated. Secondly ... how do i make it so i can use my own particle and not the default star shape. Because i don't want the star while I'm flying so if you know how to make the particle use my own decal that would be appreciated thank you, ~Fin

function Fly()

if Flying and Player and Torso and Humanoid and Humanoid.Health > 0 then

    local Momentum = Vector3.new(0, 0, 0)
    local LastMomentum = Vector3.new(0, 0, 0)
    local LastTilt = 0
    local CurrentSpeed = Speed.MaxSpeed
    local Inertia = (1 - (Speed.CurrentSpeed / CurrentSpeed))
    fire=Instance.new("ParticleEmitter")
    fire.Parent=script.Parent.Parent["Left Leg"]
    fire2=Instance.new("ParticleEmitter")
    fire2.Parent=script.Parent.Parent["Right Leg"]
    fire3=Instance.new("ParticleEmitter")
    fire3.Parent=script.Parent.Parent["Left Arm"]
    fire4=Instance.new("ParticleEmitter")
    fire4.Parent=script.Parent.Parent["Right Arm"]
    fire5=Instance.new("ParticleEmitter")
    fire5.Parent=script.Parent.Parent.Torso
    fire6=Instance.new("ParticleEmitter")
    fire6.Parent=script.Parent.Parent.Head
    BodyVelocity.maxForce = Vector3.new(1, 1, 1) * (10 ^ 6) 

    BodyGyro.maxTorque = Vector3.new(BodyGyro.P, BodyGyro.P, BodyGyro.P)
    BodyGyro.cframe = Torso.CFrame

    while Flying and Torso and Humanoid and Humanoid.Health > 0 do

        if CurrentSpeed ~= Speed.MaxSpeed then
            CurrentSpeed = Speed.MaxSpeed
            Inertia = (1 - (Speed.CurrentSpeed / CurrentSpeed))
        end

        local Direction = CurrentCamera.CoordinateFrame:vectorToWorldSpace(Vector3.new(Controls.Left.Number + Controls.Right.Number, math.abs(Controls.Forward.Number) * 0.2, Controls.Forward.Number + Controls.Backward.Number))
        local Movement = Direction * Speed.CurrentSpeed

        Momentum = (Momentum * Inertia) + Movement

        local TotalMomentum = Momentum.magnitude

        if TotalMomentum > CurrentSpeed then
            TotalMomentum = CurrentSpeed
        end

        local Tilt = ((Momentum * Vector3.new(1, 0, 1)).unit:Cross(((LastMomentum * Vector3.new(1, 0, 1)).unit))).y
        local StringTilt = tostring(Tilt)

        if StringTilt == "-1.#IND" or StringTilt == "1.#IND" or Tilt == math.huge or Tilt == -math.huge or StringTilt == tostring(0 / 0) then
            Tilt = 0
        end

        local AbsoluteTilt = math.abs(Tilt)

        if AbsoluteTilt > 0.06 or AbsoluteTilt < 0.0001 then
            if math.abs(LastTilt) > 0.0001 then
                Tilt = (LastTilt * 0.9)
            else
                Tilt = 0
            end
        else
            Tilt = ((LastTilt * 0.77) + (Tilt * 0.25))
        end

        LastTilt = Tilt

        if TotalMomentum < 0.5 then
            Momentum = Vector3.new(0, 0, 0)
            TotalMomentum = 0
            BodyGyro.cframe = CurrentCamera.CoordinateFrame
        else
            BodyGyro.cframe = CFrame.new(Vector3.new(0, 0, 0), Momentum) * CFrame.Angles(0, 0, (Tilt * -20)) * CFrame.Angles((math.pi * -0.5 * (TotalMomentum / CurrentSpeed)), 0, 0)
        end

        BodyVelocity.velocity = Momentum
        LastMomentum = Momentum
        Wait(FlyRate)

    end

    BodyVelocity.maxForce = Vector3.new(0, 0, 0)
    BodyPosition.maxForce = Vector3.new(0, 0, 0)
    BodyGyro.maxTorque = Vector3.new(0, 0, 0)

end

end

function StopFlying() Flying = false BodyVelocity.maxForce = Vector3.new(0, 0, 0) BodyPosition.maxForce = Vector3.new(0, 0, 0) BodyGyro.maxTorque = Vector3.new(0, 0, 0) script.Parent.Parent["Left Leg"]:ClearAllChildren() script.Parent.Parent["Right Leg"]:ClearAllChildren() script.Parent.Parent["Left Arm"]:ClearAllChildren() script.Parent.Parent["Right Arm"]:ClearAllChildren() script.Parent.Parent.Torso:ClearAllChildren() script.Parent.Parent.Head:ClearAllChildren() end

1 answer

Log in to vote
0
Answered by
Validark 1580 Snack Break Moderation Voter
8 years ago

If you need to clear the children of Torso without deleting the Humanoid, you can make your own custom ClearAllChildren() function (kind of)

ClearAllChildren() is equivalent to something like this:

for _, v in pairs(object:GetChildren()) do
    v:Destroy()
end

So, to ClearAllChildren() except Humanoid, add a conditional:

for _, v in pairs(script.Parent.Parent.Torso:GetChildren()) do
    if v.ClassName ~= "Humanoid" then
        v:Destroy()
    end
end

Here is a list of all the properties of ParticleEmitter. To change the Texture, modify the Texture property.

0
ok ... thank you ill try that FinickOdre123 6 — 8y
0
i tryed that and it didnt work ... did i do it wrong? FinickOdre123 6 — 8y
Ad

Answer this question