Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Help with a Fly Script?

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

✓ Accepted answer

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)

This discussion is preserved as it was. New answers, comments, and votes are closed.