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

Help with a Fly Script?

Asked by 8 years ago

My problem is that if I click really fast, the sparkles and the BodyForce doesn't get removed, therefore flying off into space. Can anyone help me?

Tool = script.Parent

--Variables

enabled = true
script.Parent.Parent.Activated:connect(function(mouse)
    print("FIRED")
    if enabled then
        print("is enabled")
        enabled = false
        script.Parent.Parent.Parent:FindFirstChild("Torso").Velocity = Vector3.new(0,0,0)
        Up = Instance.new("BodyForce")
        Up.force = Vector3.new(0,10000,0)
        Up.Parent = script.Parent.Parent.Parent:FindFirstChild("Torso")
        spark = Instance.new("Sparkles")
        spark.Parent = script.Parent.Parent.Parent:FindFirstChild("Torso")
        wait(.2)
        Up:Destroy()
        spark:Destroy()
        print("force applied")
    end
    wait(.5)
    enabled = true
end)

1 answer

Log in to vote
1
Answered by 8 years ago

for repair that you'll only need a methods called "AddItem" and you need to use that like that "AddItem(obj, time)"

Tool = script.Parent

--Variables

enabled = true
script.Parent.Parent.Activated:connect(function(mouse)
    print("FIRED")
    if enabled then
        print("is enabled")
        enabled = false
        script.Parent.Parent.Parent:FindFirstChild("Torso").Velocity = Vector3.new(0,0,0)
        Up = Instance.new("BodyForce")
        Up.force = Vector3.new(0,10000,0)
        Up.Parent = script.Parent.Parent.Parent:FindFirstChild("Torso")
        spark = Instance.new("Sparkles")
        spark.Parent = script.Parent.Parent.Parent:FindFirstChild("Torso")
        game:GetService("Debris"):AddItem(Up, 0.2)
        game:GetService("Debris"):AddItem(spark, 0.2)
        print("force applied")
    end
    wait(.5)
    enabled = true
end)

Ad

Answer this question